-
Notifications
You must be signed in to change notification settings - Fork 134
Added simple local db migration #1537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Deploying datachain with
|
| Latest commit: |
5a8a102
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a1409504.datachain-2g6.pages.dev |
| Branch Preview URL: | https://ilongin-1536-local-db-migrat.datachain-2g6.pages.dev |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
pyproject.toml
Outdated
| "ignore::DeprecationWarning:datasets.utils._dill", | ||
| "ignore::DeprecationWarning:librosa.core.intervals", | ||
| "ignore::FutureWarning:google.api_core._python_version_support", # Python 3.10 EOL warning | ||
| "ignore:The default formatters.*will be replaced by ruff:FutureWarning:datamodel_code_generator.*", # Formatter migration warning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's not do this please, properly fix this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in another PR
pyproject.toml
Outdated
| "pydantic", | ||
| "jmespath>=1.0", | ||
| "datamodel-code-generator>=0.25", | ||
| "datamodel-code-generator>=0.27", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's do these changes and Pillow as a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed and merged
| parts.append(f"DEFAULT {default_val}") | ||
|
|
||
| column_def = " ".join(parts) | ||
| alter_query = f"ALTER TABLE {table_name} ADD COLUMN {column_def}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can use sqlalchemy here and not build raw SQL, which is fragile/not safe.
Brief example:
from sqlalchemy.schema import AddColumn
table.append_column(col)
self.execute(AddColumn(table, col))Haven't checked it but it looks more robust to me, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no AddColumn any more, SQLAlchemy stopped supporting it a while ago since it wasn't stable / portable I guess. Only thing left is to create raw query.
…in-ai/datachain into ilongin/1536-local-db-migrations
Simple DB automatic migration for SQLite to add new columns to existing DB.
Note that this code doesn't cover:
Migration runs on every SQLite DB initialization but it is fast enough not to create overhead (there is a test added that measures performance)