diff --git a/backend/alembic/versions/0057_multi_notes.py b/backend/alembic/versions/0057_multi_notes.py index 5a4f2a246..1fa2e7254 100644 --- a/backend/alembic/versions/0057_multi_notes.py +++ b/backend/alembic/versions/0057_multi_notes.py @@ -10,8 +10,6 @@ from alembic import op from sqlalchemy import text -from utils.database import is_mariadb, is_mysql - # revision identifiers, used by Alembic. revision = "0057_multi_notes" down_revision = "0056_gamelist_xml" @@ -57,17 +55,6 @@ def upgrade() -> None: op.create_index("idx_rom_notes_rom_user", "rom_notes", ["rom_id", "user_id"]) op.create_index("idx_rom_notes_title", "rom_notes", ["title"]) - # Get connection for manual index creation - connection = op.get_bind() - - # For MariaDB compatibility, we limit the content index length - if is_mysql(connection) or is_mariadb(connection): - connection.execute( - text("CREATE INDEX idx_rom_notes_content ON rom_notes (content(100))") - ) - else: - op.create_index("idx_rom_notes_content", "rom_notes", ["content"]) - # Add default values to old note columns to prevent insertion errors # This allows new rom_user records to be created without specifying note fields op.alter_column( @@ -87,7 +74,7 @@ def upgrade() -> None: # Migrate existing notes from rom_user to rom_notes table # Both note_raw_markdown and note_is_public columns exist from previous migrations - + connection = op.get_bind() result = connection.execute( text( """ @@ -124,8 +111,6 @@ def upgrade() -> None: def downgrade() -> None: """Drop the rom_notes table and restore note columns to rom_user.""" - connection = op.get_bind() - # Add back the old columns to rom_user op.add_column( "rom_user", @@ -139,7 +124,7 @@ def downgrade() -> None: ) # Migrate notes back to rom_user (take first note per user/rom) - + connection = op.get_bind() result = connection.execute( text( """ @@ -168,17 +153,6 @@ def downgrade() -> None: }, ) - # Drop indexes and table - if is_mysql(connection) or is_mariadb(connection): - # The content index was created with a specific length using raw SQL for MySQL/MariaDB, - # so we drop it with raw SQL as well. - connection.execute( - text("DROP INDEX IF EXISTS idx_rom_notes_content ON rom_notes") - ) - else: - # For other databases, the content index was created with op.create_index. - op.drop_index("idx_rom_notes_content", table_name="rom_notes") - # These indexes were created with op.create_index for all dialects. op.drop_index("idx_rom_notes_title", table_name="rom_notes") op.drop_index("idx_rom_notes_rom_user", table_name="rom_notes")