mirror of
https://github.com/KohakuBlueleaf/KohakuHub.git
synced 2026-04-30 17:37:51 -05:00
fix scripts bugs
This commit is contained in:
@@ -95,38 +95,50 @@ def migrate_sqlite():
|
|||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
"""Run migration 014."""
|
"""Run migration 014.
|
||||||
print("\n" + "=" * 60)
|
|
||||||
print(f"Migration {MIGRATION_NUMBER}: Add UserExternalToken table")
|
|
||||||
print("=" * 60)
|
|
||||||
|
|
||||||
# Connect to database
|
Returns:
|
||||||
|
True if successful or already applied, False otherwise
|
||||||
|
"""
|
||||||
db.connect(reuse_if_open=True)
|
db.connect(reuse_if_open=True)
|
||||||
|
|
||||||
# Check if should skip
|
try:
|
||||||
if should_skip_due_to_future_migrations(MIGRATION_NUMBER, db, cfg):
|
# Check if should skip due to future migrations
|
||||||
print(
|
if should_skip_due_to_future_migrations(MIGRATION_NUMBER, db, cfg):
|
||||||
f"\n⚠️ Skipping migration {MIGRATION_NUMBER} - already applied or superseded by future migrations\n"
|
print(
|
||||||
)
|
f"Migration {MIGRATION_NUMBER}: Skipped (superseded by future migration)"
|
||||||
return
|
)
|
||||||
|
return True
|
||||||
|
|
||||||
# Check if already applied
|
# Check if already applied
|
||||||
if is_applied(db, cfg):
|
if is_applied(db, cfg):
|
||||||
print(
|
print(
|
||||||
f"\n✓ Migration {MIGRATION_NUMBER} already applied (UserExternalToken table exists)\n"
|
f"Migration {MIGRATION_NUMBER}: Already applied (UserExternalToken table exists)"
|
||||||
)
|
)
|
||||||
return
|
return True
|
||||||
|
|
||||||
# Run migration in transaction
|
print("=" * 70)
|
||||||
print(f"\nApplying migration {MIGRATION_NUMBER}...\n")
|
print(f"Migration {MIGRATION_NUMBER}: Add UserExternalToken table")
|
||||||
|
print("=" * 70)
|
||||||
|
|
||||||
with db.atomic():
|
# Run migration in transaction
|
||||||
if cfg.app.db_backend == "postgres":
|
with db.atomic():
|
||||||
migrate_postgres()
|
if cfg.app.db_backend == "postgres":
|
||||||
else:
|
migrate_postgres()
|
||||||
migrate_sqlite()
|
else:
|
||||||
|
migrate_sqlite()
|
||||||
|
|
||||||
print(f"\n✓ Migration {MIGRATION_NUMBER} completed successfully!\n")
|
print("\n" + "=" * 70)
|
||||||
|
print(f"Migration {MIGRATION_NUMBER}: ✓ Completed Successfully")
|
||||||
|
print("=" * 70)
|
||||||
|
return True
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"\n✗ Migration {MIGRATION_NUMBER} failed: {e}")
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
traceback.print_exc()
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user