Mercurial > libervia-backend
annotate libervia/backend/memory/migration/versions/4b002773cf92_add_origin_id_column_to_history_and_.py @ 4150:26534d959d2d
Plugin XEP-0384: rename the pun names "OLDMEMO" and "TWOMEMO" to "OMEMO_legacy" and "OMEMO" for clarity.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 22 Nov 2023 14:45:26 +0100 |
parents | 4b842c1fb686 |
children | 0d7bb4df2343 |
rev | line source |
---|---|
3796
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 """add origin_id column to history and adapt constraints |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 Revision ID: 4b002773cf92 |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 Revises: 79e5f3313fa4 |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 Create Date: 2022-06-13 16:10:39.711634 |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 """ |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 from alembic import op |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 import sqlalchemy as sa |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # revision identifiers, used by Alembic. |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 revision = '4b002773cf92' |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 down_revision = '79e5f3313fa4' |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 branch_labels = None |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 depends_on = None |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 def upgrade(): |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 with op.batch_alter_table('history', schema=None) as batch_op: |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 batch_op.add_column(sa.Column('origin_id', sa.Text(), nullable=True)) |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 batch_op.create_unique_constraint('uq_origin_id', ['profile_id', 'origin_id', 'source']) |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 with op.batch_alter_table('message', schema=None) as batch_op: |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 batch_op.alter_column('history_uid', |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 existing_type=sa.TEXT(), |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 nullable=False) |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 batch_op.alter_column('message', |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 existing_type=sa.TEXT(), |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 nullable=False) |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 with op.batch_alter_table('subject', schema=None) as batch_op: |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 batch_op.alter_column('history_uid', |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 existing_type=sa.TEXT(), |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 nullable=False) |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 batch_op.alter_column('subject', |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 existing_type=sa.TEXT(), |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 nullable=False) |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 def downgrade(): |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 with op.batch_alter_table('subject', schema=None) as batch_op: |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 batch_op.alter_column('subject', |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 existing_type=sa.TEXT(), |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 nullable=True) |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 batch_op.alter_column('history_uid', |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 existing_type=sa.TEXT(), |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 nullable=True) |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 with op.batch_alter_table('message', schema=None) as batch_op: |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 batch_op.alter_column('message', |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 existing_type=sa.TEXT(), |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 nullable=True) |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 batch_op.alter_column('history_uid', |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 existing_type=sa.TEXT(), |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 nullable=True) |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
58 with op.batch_alter_table('history', schema=None) as batch_op: |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 batch_op.drop_constraint('uq_origin_id', type_='unique') |
24c1c06c865b
core (memory/mapping): add `origin_id` column to History + constraints update:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 batch_op.drop_column('origin_id') |