mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-28 11:54:32 +02:00
migrate --list is now read-only
pending() and applied() no longer create the _sqlite_migrations table or perform the one-way legacy schema upgrade - that now only happens in apply(). The CLI --list path no longer creates the database file when it does not exist. applied() results are now explicitly ordered by insertion. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UnLnhsH25Nnv7LHhekUfPd
This commit is contained in:
parent
0bad21280f
commit
30cc95c0a6
6 changed files with 67 additions and 15 deletions
|
|
@ -3387,13 +3387,19 @@ def migrate(db_path, migrations, stop_before, list_, verbose):
|
|||
if not migration_sets:
|
||||
raise click.ClickException("No migrations.py files found")
|
||||
|
||||
db = sqlite_utils.Database(db_path)
|
||||
_register_db_for_cleanup(db)
|
||||
|
||||
if list_:
|
||||
if pathlib.Path(db_path).exists():
|
||||
db = sqlite_utils.Database(db_path)
|
||||
else:
|
||||
# Listing is read-only - don't create the database file
|
||||
db = sqlite_utils.Database(memory=True)
|
||||
_register_db_for_cleanup(db)
|
||||
_display_migration_list(db, migration_sets)
|
||||
return
|
||||
|
||||
db = sqlite_utils.Database(db_path)
|
||||
_register_db_for_cleanup(db)
|
||||
|
||||
prev_schema = db.schema
|
||||
if verbose:
|
||||
click.echo("Migrating {}".format(db_path))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue