Skip to content

Commit e2df40d

Browse files
committed
[ROMM-2877] Drop index on rom file content
1 parent 9fe49ba commit e2df40d

File tree

1 file changed

+2
-28
lines changed

1 file changed

+2
-28
lines changed

backend/alembic/versions/0057_multi_notes.py

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
from alembic import op
1111
from sqlalchemy import text
1212

13-
from utils.database import is_mariadb, is_mysql
14-
1513
# revision identifiers, used by Alembic.
1614
revision = "0057_multi_notes"
1715
down_revision = "0056_gamelist_xml"
@@ -57,17 +55,6 @@ def upgrade() -> None:
5755
op.create_index("idx_rom_notes_rom_user", "rom_notes", ["rom_id", "user_id"])
5856
op.create_index("idx_rom_notes_title", "rom_notes", ["title"])
5957

60-
# Get connection for manual index creation
61-
connection = op.get_bind()
62-
63-
# For MariaDB compatibility, we limit the content index length
64-
if is_mysql(connection) or is_mariadb(connection):
65-
connection.execute(
66-
text("CREATE INDEX idx_rom_notes_content ON rom_notes (content(100))")
67-
)
68-
else:
69-
op.create_index("idx_rom_notes_content", "rom_notes", ["content"])
70-
7158
# Add default values to old note columns to prevent insertion errors
7259
# This allows new rom_user records to be created without specifying note fields
7360
op.alter_column(
@@ -87,7 +74,7 @@ def upgrade() -> None:
8774

8875
# Migrate existing notes from rom_user to rom_notes table
8976
# Both note_raw_markdown and note_is_public columns exist from previous migrations
90-
77+
connection = op.get_bind()
9178
result = connection.execute(
9279
text(
9380
"""
@@ -124,8 +111,6 @@ def upgrade() -> None:
124111
def downgrade() -> None:
125112
"""Drop the rom_notes table and restore note columns to rom_user."""
126113

127-
connection = op.get_bind()
128-
129114
# Add back the old columns to rom_user
130115
op.add_column(
131116
"rom_user",
@@ -139,7 +124,7 @@ def downgrade() -> None:
139124
)
140125

141126
# Migrate notes back to rom_user (take first note per user/rom)
142-
127+
connection = op.get_bind()
143128
result = connection.execute(
144129
text(
145130
"""
@@ -168,17 +153,6 @@ def downgrade() -> None:
168153
},
169154
)
170155

171-
# Drop indexes and table
172-
if is_mysql(connection) or is_mariadb(connection):
173-
# The content index was created with a specific length using raw SQL for MySQL/MariaDB,
174-
# so we drop it with raw SQL as well.
175-
connection.execute(
176-
text("DROP INDEX IF EXISTS idx_rom_notes_content ON rom_notes")
177-
)
178-
else:
179-
# For other databases, the content index was created with op.create_index.
180-
op.drop_index("idx_rom_notes_content", table_name="rom_notes")
181-
182156
# These indexes were created with op.create_index for all dialects.
183157
op.drop_index("idx_rom_notes_title", table_name="rom_notes")
184158
op.drop_index("idx_rom_notes_rom_user", table_name="rom_notes")

0 commit comments

Comments
 (0)