Mercurial > libervia-backend
comparison libervia/backend/memory/migration/versions/4b002773cf92_add_origin_id_column_to_history_and_.py @ 4270:0d7bb4df2343
Reformatted code base using black.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 19 Jun 2024 18:44:57 +0200 |
parents | 4b842c1fb686 |
children |
comparison
equal
deleted
inserted
replaced
4269:64a85ce8be70 | 4270:0d7bb4df2343 |
---|---|
3 Revision ID: 4b002773cf92 | 3 Revision ID: 4b002773cf92 |
4 Revises: 79e5f3313fa4 | 4 Revises: 79e5f3313fa4 |
5 Create Date: 2022-06-13 16:10:39.711634 | 5 Create Date: 2022-06-13 16:10:39.711634 |
6 | 6 |
7 """ | 7 """ |
8 | |
8 from alembic import op | 9 from alembic import op |
9 import sqlalchemy as sa | 10 import sqlalchemy as sa |
10 | 11 |
11 | 12 |
12 # revision identifiers, used by Alembic. | 13 # revision identifiers, used by Alembic. |
13 revision = '4b002773cf92' | 14 revision = "4b002773cf92" |
14 down_revision = '79e5f3313fa4' | 15 down_revision = "79e5f3313fa4" |
15 branch_labels = None | 16 branch_labels = None |
16 depends_on = None | 17 depends_on = None |
17 | 18 |
18 | 19 |
19 def upgrade(): | 20 def upgrade(): |
20 with op.batch_alter_table('history', schema=None) as batch_op: | 21 with op.batch_alter_table("history", schema=None) as batch_op: |
21 batch_op.add_column(sa.Column('origin_id', sa.Text(), nullable=True)) | 22 batch_op.add_column(sa.Column("origin_id", sa.Text(), nullable=True)) |
22 batch_op.create_unique_constraint('uq_origin_id', ['profile_id', 'origin_id', 'source']) | 23 batch_op.create_unique_constraint( |
24 "uq_origin_id", ["profile_id", "origin_id", "source"] | |
25 ) | |
23 | 26 |
24 with op.batch_alter_table('message', schema=None) as batch_op: | 27 with op.batch_alter_table("message", schema=None) as batch_op: |
25 batch_op.alter_column('history_uid', | 28 batch_op.alter_column("history_uid", existing_type=sa.TEXT(), nullable=False) |
26 existing_type=sa.TEXT(), | 29 batch_op.alter_column("message", existing_type=sa.TEXT(), nullable=False) |
27 nullable=False) | |
28 batch_op.alter_column('message', | |
29 existing_type=sa.TEXT(), | |
30 nullable=False) | |
31 | 30 |
32 with op.batch_alter_table('subject', schema=None) as batch_op: | 31 with op.batch_alter_table("subject", schema=None) as batch_op: |
33 batch_op.alter_column('history_uid', | 32 batch_op.alter_column("history_uid", existing_type=sa.TEXT(), nullable=False) |
34 existing_type=sa.TEXT(), | 33 batch_op.alter_column("subject", existing_type=sa.TEXT(), nullable=False) |
35 nullable=False) | |
36 batch_op.alter_column('subject', | |
37 existing_type=sa.TEXT(), | |
38 nullable=False) | |
39 | 34 |
40 | 35 |
41 def downgrade(): | 36 def downgrade(): |
42 with op.batch_alter_table('subject', schema=None) as batch_op: | 37 with op.batch_alter_table("subject", schema=None) as batch_op: |
43 batch_op.alter_column('subject', | 38 batch_op.alter_column("subject", existing_type=sa.TEXT(), nullable=True) |
44 existing_type=sa.TEXT(), | 39 batch_op.alter_column("history_uid", existing_type=sa.TEXT(), nullable=True) |
45 nullable=True) | |
46 batch_op.alter_column('history_uid', | |
47 existing_type=sa.TEXT(), | |
48 nullable=True) | |
49 | 40 |
50 with op.batch_alter_table('message', schema=None) as batch_op: | 41 with op.batch_alter_table("message", schema=None) as batch_op: |
51 batch_op.alter_column('message', | 42 batch_op.alter_column("message", existing_type=sa.TEXT(), nullable=True) |
52 existing_type=sa.TEXT(), | 43 batch_op.alter_column("history_uid", existing_type=sa.TEXT(), nullable=True) |
53 nullable=True) | |
54 batch_op.alter_column('history_uid', | |
55 existing_type=sa.TEXT(), | |
56 nullable=True) | |
57 | 44 |
58 with op.batch_alter_table('history', schema=None) as batch_op: | 45 with op.batch_alter_table("history", schema=None) as batch_op: |
59 batch_op.drop_constraint('uq_origin_id', type_='unique') | 46 batch_op.drop_constraint("uq_origin_id", type_="unique") |
60 batch_op.drop_column('origin_id') | 47 batch_op.drop_column("origin_id") |