Skip to content

Commit

Permalink
update migrations to handle sqllite
Browse files Browse the repository at this point in the history
  • Loading branch information
sadpandajoe committed Aug 15, 2024
1 parent b394083 commit 5f49557
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,18 @@


def upgrade():
drop_fks_for_table("sl_dataset_columns")
op.drop_table("sl_dataset_columns")
bind = op.get_bind()

# Determine if we're using SQLite
if bind.dialect.name == "sqlite":
# Use batch mode for SQLite
with op.batch_alter_table("sl_dataset_columns") as batch_op:
drop_fks_for_table("sl_dataset_columns")
batch_op.drop_table("sl_dataset_columns")
else:
# Non-SQLite: Directly drop the foreign keys and table
drop_fks_for_table("sl_dataset_columns")
op.drop_table("sl_dataset_columns")


def downgrade():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,18 @@


def upgrade():
drop_fks_for_table("sl_table_columns")
op.drop_table("sl_table_columns")
bind = op.get_bind()

# Determine if we're using SQLite
if bind.dialect.name == "sqlite":
# Use batch mode for SQLite
with op.batch_alter_table("sl_table_columns") as batch_op:
drop_fks_for_table("sl_table_columns")
batch_op.drop_table("sl_table_columns")
else:
# Non-SQLite: Directly drop the foreign keys and table
drop_fks_for_table("sl_table_columns")
op.drop_table("sl_table_columns")


def downgrade():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,18 @@


def upgrade():
drop_fks_for_table("sl_dataset_tables")
op.drop_table("sl_dataset_tables")
bind = op.get_bind()

# Determine if we're using SQLite
if bind.dialect.name == "sqlite":
# Use batch mode for SQLite
with op.batch_alter_table("sl_dataset_tables") as batch_op:
drop_fks_for_table("sl_dataset_tables")
batch_op.drop_table("sl_dataset_tables")
else:
# Non-SQLite: Directly drop the foreign keys and table
drop_fks_for_table("sl_dataset_tables")
op.drop_table("sl_dataset_tables")


def downgrade():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,18 @@


def upgrade():
drop_fks_for_table("sl_dataset_users")
op.drop_table("sl_dataset_users")
bind = op.get_bind()

# Determine if we're using SQLite
if bind.dialect.name == "sqlite":
# Use batch mode for SQLite
with op.batch_alter_table("sl_dataset_users") as batch_op:
drop_fks_for_table("sl_dataset_users")
batch_op.drop_table("sl_dataset_users")
else:
# Non-SQLite: Directly drop the foreign keys and table
drop_fks_for_table("sl_dataset_users")
op.drop_table("sl_dataset_users")


def downgrade():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,18 @@


def upgrade():
drop_fks_for_table("sl_columns")
op.drop_table("sl_columns")
bind = op.get_bind()

# Determine if we're using SQLite
if bind.dialect.name == "sqlite":
# Use batch mode for SQLite
with op.batch_alter_table("sl_columns") as batch_op:
drop_fks_for_table("sl_columns")
batch_op.drop_table("sl_columns")
else:
# Non-SQLite: Directly drop the foreign keys and table
drop_fks_for_table("sl_columns")
op.drop_table("sl_columns")


def downgrade():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,18 @@


def upgrade():
drop_fks_for_table("sl_tables")
op.drop_table("sl_tables")
bind = op.get_bind()

# Determine if we're using SQLite
if bind.dialect.name == "sqlite":
# Use batch mode for SQLite
with op.batch_alter_table("sl_tables") as batch_op:
drop_fks_for_table("sl_tables")
batch_op.drop_table("sl_tables")
else:
# Non-SQLite: Directly drop the foreign keys and table
drop_fks_for_table("sl_tables")
op.drop_table("sl_tables")


def downgrade():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,18 @@


def upgrade():
drop_fks_for_table("sl_datasets")
op.drop_table("sl_datasets")
bind = op.get_bind()

# Determine if we're using SQLite
if bind.dialect.name == "sqlite":
# Use batch mode for SQLite
with op.batch_alter_table("sl_datasets") as batch_op:
drop_fks_for_table("sl_datasets")
batch_op.drop_table("sl_datasets")
else:
# Non-SQLite: Directly drop the foreign keys and table
drop_fks_for_table("sl_datasets")
op.drop_table("sl_datasets")


def downgrade():
Expand Down

0 comments on commit 5f49557

Please sign in to comment.