Skip to content

Commit

Permalink
Fix edit index upgrade on postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed May 29, 2019
1 parent 4724333 commit ff257fc
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions alembic/versions/9e9c89b0b877_add_edit_index_to_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '9e9c89b0b877'
down_revision = '17574c57f3f8'
Expand All @@ -24,7 +23,7 @@ def upgrade():
sa.Column('tg_space', sa.Integer),
sa.Column('edit_index', sa.Integer),
sa.PrimaryKeyConstraint('tgid', 'tg_space', 'edit_index'),
sa.UniqueConstraint("mxid", "mx_room", "tg_space", name="_mx_id_room"))
sa.UniqueConstraint("mxid", "mx_room", "tg_space", name="_mx_id_room_2"))
c = op.get_bind()
c.execute("INSERT INTO _message_temp (mxid, mx_room, tgid, tg_space, edit_index) "
"SELECT message.mxid, message.mx_room, message.tgid, message.tg_space, 0 "
Expand All @@ -33,7 +32,6 @@ def upgrade():
c.execute("ALTER TABLE _message_temp RENAME TO message")



def downgrade():
op.create_table('_message_temp',
sa.Column('mxid', sa.String),
Expand All @@ -45,6 +43,6 @@ def downgrade():
c = op.get_bind()
c.execute("INSERT INTO _message_temp (mxid, mx_room, tgid, tg_space) "
"SELECT message.mxid, message.mx_room, message.tgid, message.tg_space "
"FROM portal")
"FROM message")
c.execute("DROP TABLE message")
c.execute("ALTER TABLE _message_temp RENAME TO message")

0 comments on commit ff257fc

Please sign in to comment.