Mercurial > libervia-backend
annotate libervia/backend/memory/migration/versions/610345f77e75_add_version_id_to_history.py @ 4250:4b6b812f485a
plugin app manager: Add an app configuration file for PeerTube.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 31 May 2024 11:08:22 +0200 |
parents | 23d21daed216 |
children | 0d7bb4df2343 |
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 """ |
23d21daed216
core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 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
|
9 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
|
10 |
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 # revision identifiers, used by Alembic. |
23d21daed216
core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 revision = '610345f77e75' |
23d21daed216
core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 down_revision = '2ab01aa1f686' |
23d21daed216
core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 branch_labels = None |
23d21daed216
core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 depends_on = None |
23d21daed216
core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 |
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 def upgrade(): |
23d21daed216
core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 with op.batch_alter_table('history', schema=None) as batch_op: |
23d21daed216
core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 batch_op.add_column(sa.Column('version_id', sa.Integer(), server_default=sa.text('1'), nullable=False)) |
23d21daed216
core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 |
23d21daed216
core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 |
23d21daed216
core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 def downgrade(): |
23d21daed216
core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 with op.batch_alter_table('history', schema=None) as batch_op: |
23d21daed216
core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 batch_op.drop_column('version_id') |