mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-03 03:37:28 +01:00
Fix error in old migrations caused by dependency updates
This commit is contained in:
parent
286a598c77
commit
1a8b6a23dd
@ -12,7 +12,7 @@ import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
from sqlalchemy import orm
|
||||
from sqlalchemy import orm, text
|
||||
from app.models import User, UserRank
|
||||
|
||||
revision = '105d4c740ad6'
|
||||
@ -22,8 +22,8 @@ depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("COMMIT")
|
||||
op.execute("ALTER TYPE userrank ADD VALUE 'BOT' AFTER 'EDITOR'")
|
||||
op.execute(text("COMMIT"))
|
||||
op.execute(text("ALTER TYPE userrank ADD VALUE 'BOT' AFTER 'EDITOR'"))
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
@ -7,6 +7,7 @@ Create Date: 2021-08-16 17:17:12.060257
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
@ -17,8 +18,8 @@ depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("COMMIT")
|
||||
op.execute("ALTER TYPE userrank ADD VALUE 'APPROVER' BEFORE 'EDITOR'")
|
||||
op.execute(text("COMMIT"))
|
||||
op.execute(text("ALTER TYPE userrank ADD VALUE 'APPROVER' BEFORE 'EDITOR'"))
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
@ -7,6 +7,7 @@ Create Date: 2022-01-27 18:50:11.705061
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
@ -46,9 +47,9 @@ def upgrade():
|
||||
SELECT parse_websearch('pg_catalog.simple', search_query);
|
||||
$$ LANGUAGE SQL IMMUTABLE;"""
|
||||
|
||||
op.execute(command)
|
||||
op.execute(text(command))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.execute('DROP FUNCTION public.parse_websearch(regconfig, text);')
|
||||
op.execute('DROP FUNCTION public.parse_websearch(text);')
|
||||
op.execute(text('DROP FUNCTION public.parse_websearch(regconfig, text);'))
|
||||
op.execute(text('DROP FUNCTION public.parse_websearch(text);'))
|
||||
|
@ -6,6 +6,7 @@ Create Date: 2018-05-25 17:53:13.215127
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
from sqlalchemy import text
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3f4d7cd8401f'
|
||||
@ -17,8 +18,8 @@ depends_on = None
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn.execute("ALTER TYPE packagepropertykey ADD VALUE 'harddeps'")
|
||||
conn.execute("ALTER TYPE packagepropertykey ADD VALUE 'softdeps'")
|
||||
conn.execute(text("ALTER TYPE packagepropertykey ADD VALUE 'harddeps'"))
|
||||
conn.execute(text("ALTER TYPE packagepropertykey ADD VALUE 'softdeps'"))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@ Create Date: 2020-12-04 22:30:33.420071
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from sqlalchemy import text
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3f5836a3df5c'
|
||||
@ -22,9 +22,9 @@ def upgrade():
|
||||
nullable=True,
|
||||
existing_server_default=sa.text("''::character varying"))
|
||||
|
||||
op.execute("""
|
||||
op.execute(text("""
|
||||
UPDATE "user" SET password=NULL WHERE password=''
|
||||
""")
|
||||
"""))
|
||||
op.create_check_constraint("CK_password", "user",
|
||||
"password IS NULL OR password != ''")
|
||||
|
||||
|
@ -6,6 +6,7 @@ Create Date: 2019-01-29 02:57:50.279918
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
from sqlalchemy import text
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '7ff57806ffd5'
|
||||
@ -16,7 +17,7 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.execute("""
|
||||
op.execute(text("""
|
||||
DROP TYPE IF EXISTS tsq_state CASCADE;
|
||||
|
||||
CREATE TYPE tsq_state AS (
|
||||
@ -237,7 +238,7 @@ RETURNS ANYARRAY AS $$
|
||||
WHERE index NOT IN (SELECT position FROM replaced_positions)
|
||||
), $1[1:0]);
|
||||
$$ LANGUAGE SQL IMMUTABLE;
|
||||
""")
|
||||
"""))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@ Create Date: 2020-07-12 01:33:19.499459
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
from sqlalchemy import text
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '838081950f27'
|
||||
@ -15,11 +16,11 @@ depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("""
|
||||
op.execute(text("""
|
||||
DELETE FROM provides AS t USING meta_package AS m WHERE t.metapackage_id = m.id AND NOT (m.name ~* '^[a-z0-9_]+$');
|
||||
DELETE FROM dependency AS t USING meta_package AS m WHERE t.meta_package_id = m.id AND NOT (m.name ~* '^[a-z0-9_]+$');
|
||||
DELETE FROM meta_package WHERE NOT (name ~* '^[a-z0-9_]+$');
|
||||
""")
|
||||
"""))
|
||||
|
||||
op.create_check_constraint("mp_name_valid", "meta_package", "name ~* '^[a-z0-9_]+$'")
|
||||
|
||||
|
@ -6,6 +6,7 @@ Create Date: 2021-05-03 22:21:02.167758
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
@ -19,7 +20,7 @@ def upgrade():
|
||||
op.alter_column('user', 'email_confirmed_at',
|
||||
existing_type=postgresql.TIMESTAMP(),
|
||||
nullable=True)
|
||||
op.execute("""UPDATE "user" SET email_confirmed_at = NULL WHERE email_confirmed_at < '2016-01-01'::date""")
|
||||
op.execute(text("""UPDATE "user" SET email_confirmed_at = NULL WHERE email_confirmed_at < '2016-01-01'::date"""))
|
||||
|
||||
|
||||
def downgrade():
|
||||
@ -27,4 +28,4 @@ def downgrade():
|
||||
existing_type=postgresql.TIMESTAMP(),
|
||||
nullable=False)
|
||||
op.execute(
|
||||
"""UPDATE "user" SET email_confirmed_at = '2004-01-01'::date WHERE email_confirmed_at IS NULL""")
|
||||
text("""UPDATE "user" SET email_confirmed_at = '2004-01-01'::date WHERE email_confirmed_at IS NULL"""))
|
||||
|
@ -7,6 +7,7 @@ Create Date: 2021-11-24 17:12:33.893988
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
@ -17,7 +18,7 @@ depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("DELETE FROM user_email_verification")
|
||||
op.execute(text("DELETE FROM user_email_verification"))
|
||||
op.add_column('user', sa.Column('created_at', sa.DateTime(), nullable=True))
|
||||
op.add_column('user_email_verification', sa.Column('created_at', sa.DateTime(), nullable=False))
|
||||
|
||||
|
@ -6,6 +6,7 @@ Create Date: 2020-12-10 16:42:28.086146
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
from sqlalchemy import text
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'a9c1c08bf956'
|
||||
@ -14,14 +15,14 @@ branch_labels = None
|
||||
def upgrade():
|
||||
op.alter_column('api_token', 'access_token', nullable=False)
|
||||
op.alter_column('package', 'author_id', nullable=False)
|
||||
op.execute("""UPDATE package SET "state"='WIP' WHERE "state" IS NULL""")
|
||||
op.execute(text("""UPDATE package SET "state"='WIP' WHERE "state" IS NULL"""))
|
||||
op.alter_column('package', 'state', nullable=False)
|
||||
op.alter_column('package_screenshot', 'package_id', nullable=False)
|
||||
op.alter_column('user', 'rank', nullable=False)
|
||||
op.alter_column('user_email_verification', 'user_id', nullable=False)
|
||||
op.alter_column('user_email_verification', 'email', nullable=False)
|
||||
op.alter_column('user_email_verification', 'token', nullable=False)
|
||||
op.execute("UPDATE notification SET created_at=NOW() WHERE created_at IS NULL")
|
||||
op.execute(text("UPDATE notification SET created_at=NOW() WHERE created_at IS NULL"))
|
||||
op.alter_column('notification', 'created_at', nullable=False)
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@ Create Date: 2018-05-29 20:09:56.647358
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from sqlalchemy import text
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'aa6d7b595a94'
|
||||
@ -19,7 +19,7 @@ depends_on = None
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('package', sa.Column('media_license_id', sa.Integer()))
|
||||
op.execute('UPDATE package SET media_license_id=license_id')
|
||||
op.execute(text('UPDATE package SET media_license_id=license_id'))
|
||||
op.alter_column('package', 'media_license_id', nullable=False)
|
||||
op.alter_column('package', 'license_id', existing_type=sa.INTEGER(), nullable=False)
|
||||
op.create_foreign_key(None, 'package', 'license', ['media_license_id'], ['id'])
|
||||
|
@ -6,6 +6,7 @@ Create Date: 2018-05-27 23:51:11.008936
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
from sqlalchemy import text
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'b254f55eadd2'
|
||||
@ -17,7 +18,7 @@ depends_on = None
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn.execute("ALTER TYPE userrank ADD VALUE 'TRUSTED_MEMBER'")
|
||||
conn.execute(text("ALTER TYPE userrank ADD VALUE 'TRUSTED_MEMBER'"))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
|
@ -7,6 +7,7 @@ Create Date: 2020-09-16 14:35:43.805422
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import text
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
@ -21,8 +22,8 @@ def upgrade():
|
||||
status.create(op.get_bind())
|
||||
|
||||
op.add_column('package', sa.Column('state', sa.Enum('WIP', 'CHANGES_NEEDED', 'READY_FOR_REVIEW', 'APPROVED', 'DELETED', name='packagestate'), nullable=True))
|
||||
op.execute("UPDATE package SET state='APPROVED' WHERE approved=true")
|
||||
op.execute("UPDATE package SET state='DELETED' WHERE soft_deleted=true")
|
||||
op.execute(text("UPDATE package SET state='APPROVED' WHERE approved=true"))
|
||||
op.execute(text("UPDATE package SET state='DELETED' WHERE soft_deleted=true"))
|
||||
op.drop_column('package', 'approved')
|
||||
op.drop_column('package', 'soft_deleted')
|
||||
# ### end Alembic commands ###
|
||||
|
@ -7,7 +7,7 @@ Create Date: 2020-12-05 02:29:16.706564
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from sqlalchemy import text
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'c154912eaa0c'
|
||||
@ -17,8 +17,8 @@ depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.execute("COMMIT")
|
||||
op.execute("ALTER TYPE auditseverity ADD VALUE 'USER'")
|
||||
op.execute(text("COMMIT"))
|
||||
op.execute(text("ALTER TYPE auditseverity ADD VALUE 'USER'"))
|
||||
|
||||
def downgrade():
|
||||
pass
|
||||
|
@ -7,7 +7,7 @@ Create Date: 2020-07-08 21:03:51.856561
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from sqlalchemy import orm
|
||||
from sqlalchemy import orm, text
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'cb6ab141c522'
|
||||
@ -29,7 +29,7 @@ def upgrade():
|
||||
bind = op.get_bind()
|
||||
session = orm.Session(bind=bind)
|
||||
|
||||
op.execute('INSERT INTO maintainers (package_id, user_id) SELECT id, author_id FROM package;')
|
||||
op.execute(text('INSERT INTO maintainers (package_id, user_id) SELECT id, author_id FROM package;'))
|
||||
|
||||
session.commit()
|
||||
|
||||
|
@ -7,7 +7,7 @@ Create Date: 2020-07-09 00:20:39.501355
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from sqlalchemy import text
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'dd27f1311a90'
|
||||
@ -19,9 +19,9 @@ depends_on = None
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('package', sa.Column('score_downloads', sa.Float(), nullable=False, server_default="0"))
|
||||
op.execute("""
|
||||
op.execute(text("""
|
||||
UPDATE "package" SET "score_downloads"="score";
|
||||
""")
|
||||
"""))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
|
@ -7,6 +7,7 @@ Create Date: 2020-07-17 23:47:51.096874
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from sqlalchemy import text
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'dff4b87e4a76'
|
||||
@ -19,9 +20,9 @@ def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('package', sa.Column('approved_at', sa.DateTime(), nullable=True, server_default=None))
|
||||
|
||||
op.execute("""
|
||||
op.execute(text("""
|
||||
UPDATE package SET approved_at=created_at WHERE approved;
|
||||
""")
|
||||
"""))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@ Create Date: 2020-12-06 03:16:59.988464
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
from sqlalchemy import text
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'e1bf78a597a2'
|
||||
@ -18,7 +18,7 @@ depends_on = None
|
||||
|
||||
def upgrade():
|
||||
op.add_column('package_screenshot', sa.Column('order', sa.Integer(), nullable=True))
|
||||
op.execute("""UPDATE package_screenshot SET "order" = id""")
|
||||
op.execute(text("""UPDATE package_screenshot SET "order" = id"""))
|
||||
op.alter_column('package_screenshot', 'order', nullable=False)
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@ Create Date: 2018-05-26 01:55:09.745881
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
from sqlalchemy import text
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'ea5a023711e0'
|
||||
@ -17,7 +18,7 @@ depends_on = None
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
conn = op.get_bind()
|
||||
conn.execute("ALTER TYPE userrank ADD VALUE 'BANNED'")
|
||||
conn.execute(text("ALTER TYPE userrank ADD VALUE 'BANNED'"))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@ Create Date: 2020-12-15 21:49:19.190893
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
from sqlalchemy import text
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'f565dde93553'
|
||||
@ -19,13 +19,13 @@ depends_on = None
|
||||
def upgrade():
|
||||
op.add_column('package_update_config', sa.Column('ref', sa.String(length=41), nullable=True))
|
||||
op.add_column('user_notification_preferences', sa.Column('pref_bot', sa.Integer(), nullable=True, server_default=None))
|
||||
op.execute("""UPDATE user_notification_preferences SET pref_bot=pref_new_thread""")
|
||||
op.execute(text("""UPDATE user_notification_preferences SET pref_bot=pref_new_thread"""))
|
||||
op.alter_column('user_notification_preferences', 'pref_bot',
|
||||
existing_type=sa.INTEGER(),
|
||||
nullable=False)
|
||||
|
||||
op.execute("COMMIT")
|
||||
op.execute("ALTER TYPE notificationtype ADD VALUE 'BOT'")
|
||||
op.execute(text("COMMIT"))
|
||||
op.execute(text("ALTER TYPE notificationtype ADD VALUE 'BOT'"))
|
||||
|
||||
|
||||
def downgrade():
|
||||
|
Loading…
Reference in New Issue
Block a user