-
-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
i'd like a way to add a migration config after I created a driver config.
that would let me do something like the below:
from typing import Any, Self
from sqlspec import AsyncDatabaseConfig, SQLSpec, SyncDatabaseConfig
from sqlspec.adapters.sqlite import SqliteConfig
class KS:
def __init__(self, spec: SQLSpec, config: SyncDatabaseConfig[Any, Any, Any] | AsyncDatabaseConfig[Any, Any, Any],
) -> None:
self.spec = spec
self.config = config
@classmethod
def create(cls, spec: SQLSpec, config: SyncDatabaseConfig[Any, Any, Any, ])-> Self:
self = cls(spec=spec, config=config, )
# here i'd like something like config.add_migration_coonfig(toto)
current = config.get_current_migration()
if not current:
try:
config.migrate_up(echo=True)
except Exception as e:
print(f"Migration failed: {e}")
raise e
return self
spec = SQLSpec()
config = SqliteConfig(connection_config={"database": "tt.db"},)
ks = KS.create(spec, config)
weirdly enough the above raises with a sqlspec.exceptions.SQLFileNotFoundError: SQL file 'migrations/0001_init.sql' not found but I'm positive the file exists.
also if I add a migration_config to the sqlite config above, then it finds there is one migration, and it fails because the file is not found, how can it not find the file if it detected it in the first place ?
Basic Example
No response
Drawbacks and Impact
No response
Unresolved questions
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request