mirror of
https://github.com/rommapp/romm.git
synced 2026-12-04 12:52:19 +01:00
updated 1.8 alembic version
This commit is contained in:
@@ -21,25 +21,12 @@ depends_on = None
|
||||
def upgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
|
||||
if os.getenv('ROMM_DB_DRIVER') == 'mariadb':
|
||||
op.alter_column(table_name='platforms', column_name='slug', new_column_name='fs_slug', type_=sa.String(length=50), existing_type=sa.String(length=50))
|
||||
op.add_column(table_name='platforms', column=sa.Column('slug', sa.String(length=50)))
|
||||
op.execute("INSERT INTO platforms(slug) SELECT fs_slug from platforms")
|
||||
with op.batch_alter_table("platforms") as batch_op:
|
||||
if os.getenv('ROMM_DB_DRIVER') == 'mariadb':
|
||||
batch_op.drop_constraint('PRIMARY', type_="primary")
|
||||
|
||||
with op.batch_alter_table("roms") as batch_op:
|
||||
if os.getenv('ROMM_DB_DRIVER') == 'mariadb':
|
||||
batch_op.drop_constraint('PRIMARY', type_="primary")
|
||||
batch_op.add_column(sa.Column('p_name', sa.String(length=150), nullable=True))
|
||||
batch_op.add_column(sa.Column('url_cover', sa.Text(), nullable=True))
|
||||
batch_op.alter_column('name', new_column_name='r_name', type_=sa.String(length=150), existing_type=sa.String(length=150))
|
||||
batch_op.alter_column('p_slug', existing_type=sa.String(length=50), nullable=False)
|
||||
batch_op.alter_column('file_name', existing_type=sa.String(length=450), nullable=False)
|
||||
|
||||
# Alter primary keys
|
||||
with op.batch_alter_table("platforms") as batch_op:
|
||||
if os.getenv('ROMM_DB_DRIVER') == 'mariadb':
|
||||
batch_op.execute("ALTER TABLE platforms ADD COLUMN fs_slug VARCHAR(50) NOT NULL PRIMARY KEY")
|
||||
batch_op.execute("INSERT INTO platforms(fs_slug) SELECT slug from platforms")
|
||||
elif os.getenv('ROMM_DB_DRIVER') == 'sqlite' or not os.getenv('ROMM_DB_DRIVER'):
|
||||
if os.getenv('ROMM_DB_DRIVER') == 'sqlite' or not os.getenv('ROMM_DB_DRIVER'):
|
||||
batch_op.execute("ALTER TABLE platforms RENAME TO old_platforms")
|
||||
op.create_table('platforms',
|
||||
sa.Column('igdb_id', sa.String(length=10), nullable=True),
|
||||
@@ -56,6 +43,15 @@ def upgrade() -> None:
|
||||
FROM old_platforms")
|
||||
op.drop_table('old_platforms')
|
||||
|
||||
|
||||
with op.batch_alter_table("roms") as batch_op:
|
||||
if os.getenv('ROMM_DB_DRIVER') == 'mariadb':
|
||||
batch_op.drop_constraint('PRIMARY', type_="primary")
|
||||
batch_op.add_column(sa.Column('p_name', sa.String(length=150), nullable=True))
|
||||
batch_op.add_column(sa.Column('url_cover', sa.Text(), nullable=True))
|
||||
batch_op.alter_column('name', new_column_name='r_name', type_=sa.String(length=150), existing_type=sa.String(length=150))
|
||||
batch_op.alter_column('p_slug', existing_type=sa.String(length=50), nullable=False)
|
||||
batch_op.alter_column('file_name', existing_type=sa.String(length=450), nullable=False)
|
||||
with op.batch_alter_table("roms") as batch_op:
|
||||
if os.getenv('ROMM_DB_DRIVER') == 'mariadb':
|
||||
batch_op.execute("ALTER TABLE roms ADD COLUMN id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT")
|
||||
|
||||
Reference in New Issue
Block a user