Mercurial > libervia-backend
annotate libervia/backend/memory/migration/versions/8974efc51d22_create_tables_for_pubsub_caching.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 | 4b842c1fb686 |
children | 0d7bb4df2343 |
rev | line source |
---|---|
3594
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 """create tables for Pubsub caching |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 Revision ID: 8974efc51d22 |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 Revises: 602caf848068 |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 Create Date: 2021-07-27 16:38:54.658212 |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 """ |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 from alembic import op |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 import sqlalchemy as sa |
4071
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
3594
diff
changeset
|
10 from libervia.backend.memory.sqla_mapping import JID, Xml |
3594
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # revision identifiers, used by Alembic. |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 revision = '8974efc51d22' |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 down_revision = '602caf848068' |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 branch_labels = None |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 depends_on = None |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 def upgrade(): |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 # ### commands auto generated by Alembic - please adjust! ### |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 op.create_table('pubsub_nodes', |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 sa.Column('id', sa.Integer(), nullable=False), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
24 sa.Column('profile_id', sa.Integer(), nullable=True), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 sa.Column('service', JID(), nullable=True), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 sa.Column('name', sa.Text(), nullable=False), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 sa.Column('subscribed', sa.Boolean(create_constraint=True, name='subscribed_bool'), nullable=False), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 sa.Column('analyser', sa.Text(), nullable=True), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 sa.Column('sync_state', sa.Enum('IN_PROGRESS', 'COMPLETED', 'ERROR', 'NO_SYNC', name='sync_state', create_constraint=True), nullable=True), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 sa.Column('sync_state_updated', sa.Float(), nullable=False), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 sa.Column('type', sa.Text(), nullable=True), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 sa.Column('subtype', sa.Text(), nullable=True), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 sa.Column('extra', sa.JSON(), nullable=True), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 sa.ForeignKeyConstraint(['profile_id'], ['profiles.id'], name=op.f('fk_pubsub_nodes_profile_id_profiles'), ondelete='CASCADE'), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 sa.PrimaryKeyConstraint('id', name=op.f('pk_pubsub_nodes')), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 sa.UniqueConstraint('profile_id', 'service', 'name', name=op.f('uq_pubsub_nodes_profile_id')) |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 ) |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 op.create_table('pubsub_items', |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 sa.Column('id', sa.Integer(), nullable=False), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 sa.Column('node_id', sa.Integer(), nullable=False), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 sa.Column('name', sa.Text(), nullable=False), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 sa.Column('data', Xml(), nullable=False), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 sa.Column('created', sa.DateTime(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 sa.Column('updated', sa.DateTime(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 sa.Column('parsed', sa.JSON(), nullable=True), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 sa.ForeignKeyConstraint(['node_id'], ['pubsub_nodes.id'], name=op.f('fk_pubsub_items_node_id_pubsub_nodes'), ondelete='CASCADE'), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 sa.PrimaryKeyConstraint('id', name=op.f('pk_pubsub_items')), |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 sa.UniqueConstraint('node_id', 'name', name=op.f('uq_pubsub_items_node_id')) |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 ) |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 # ### end Alembic commands ### |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 def downgrade(): |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 # ### commands auto generated by Alembic - please adjust! ### |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 op.drop_table('pubsub_items') |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 op.drop_table('pubsub_nodes') |
d5116197e403
migration: script to create pubsub caching tables
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 # ### end Alembic commands ### |