annotate libervia/backend/memory/migration/versions/610345f77e75_add_version_id_to_history.py @ 4272:89a0999884ac default tip @

cli (list/set): add "--comments" argument.
author Goffi <goffi@goffi.org>
date Thu, 20 Jun 2024 14:46:55 +0200
parents 0d7bb4df2343
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4152
23d21daed216 core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff changeset
1 """add "version_id" to History
23d21daed216 core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff changeset
2
23d21daed216 core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff changeset
3 Revision ID: 610345f77e75
23d21daed216 core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff changeset
4 Revises: 2ab01aa1f686
23d21daed216 core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff changeset
5 Create Date: 2023-11-20 17:33:53.544032
23d21daed216 core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff changeset
6
23d21daed216 core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff changeset
7 """
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4152
diff changeset
8
4152
23d21daed216 core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff changeset
9 from alembic import op
23d21daed216 core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff changeset
10 import sqlalchemy as sa
23d21daed216 core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff changeset
11
23d21daed216 core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff changeset
12
23d21daed216 core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # revision identifiers, used by Alembic.
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4152
diff changeset
14 revision = "610345f77e75"
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4152
diff changeset
15 down_revision = "2ab01aa1f686"
4152
23d21daed216 core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff changeset
16 branch_labels = None
23d21daed216 core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff changeset
17 depends_on = None
23d21daed216 core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff changeset
18
23d21daed216 core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff changeset
19
23d21daed216 core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff changeset
20 def upgrade():
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4152
diff changeset
21 with op.batch_alter_table("history", schema=None) as batch_op:
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4152
diff changeset
22 batch_op.add_column(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4152
diff changeset
23 sa.Column(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4152
diff changeset
24 "version_id", sa.Integer(), server_default=sa.text("1"), nullable=False
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4152
diff changeset
25 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4152
diff changeset
26 )
4152
23d21daed216 core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff changeset
27
23d21daed216 core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff changeset
28
23d21daed216 core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff changeset
29 def downgrade():
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4152
diff changeset
30 with op.batch_alter_table("history", schema=None) as batch_op:
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4152
diff changeset
31 batch_op.drop_column("version_id")