Mercurial > libervia-backend
comparison libervia/backend/memory/migration/versions/79e5f3313fa4_create_table_for_pubsub_subscriptions.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: 79e5f3313fa4 | 3 Revision ID: 79e5f3313fa4 |
4 Revises: 129ac51807e4 | 4 Revises: 129ac51807e4 |
5 Create Date: 2022-03-14 17:15:00.689871 | 5 Create Date: 2022-03-14 17:15:00.689871 |
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 from libervia.backend.memory.sqla_mapping import JID | 11 from libervia.backend.memory.sqla_mapping import JID |
11 | 12 |
12 | 13 |
13 # revision identifiers, used by Alembic. | 14 # revision identifiers, used by Alembic. |
14 revision = '79e5f3313fa4' | 15 revision = "79e5f3313fa4" |
15 down_revision = '129ac51807e4' | 16 down_revision = "129ac51807e4" |
16 branch_labels = None | 17 branch_labels = None |
17 depends_on = None | 18 depends_on = None |
18 | 19 |
19 | 20 |
20 def upgrade(): | 21 def upgrade(): |
21 op.create_table('pubsub_subs', | 22 op.create_table( |
22 sa.Column('id', sa.Integer(), nullable=False), | 23 "pubsub_subs", |
23 sa.Column('node_id', sa.Integer(), nullable=False), | 24 sa.Column("id", sa.Integer(), nullable=False), |
24 sa.Column('subscriber', JID(), nullable=True), | 25 sa.Column("node_id", sa.Integer(), nullable=False), |
25 sa.Column('state', sa.Enum('SUBSCRIBED', 'PENDING', name='state'), nullable=True), | 26 sa.Column("subscriber", JID(), nullable=True), |
26 sa.ForeignKeyConstraint(['node_id'], ['pubsub_nodes.id'], name=op.f('fk_pubsub_subs_node_id_pubsub_nodes'), ondelete='CASCADE'), | 27 sa.Column("state", sa.Enum("SUBSCRIBED", "PENDING", name="state"), nullable=True), |
27 sa.PrimaryKeyConstraint('id', name=op.f('pk_pubsub_subs')), | 28 sa.ForeignKeyConstraint( |
28 sa.UniqueConstraint('node_id', 'subscriber', name=op.f('uq_pubsub_subs_node_id')) | 29 ["node_id"], |
30 ["pubsub_nodes.id"], | |
31 name=op.f("fk_pubsub_subs_node_id_pubsub_nodes"), | |
32 ondelete="CASCADE", | |
33 ), | |
34 sa.PrimaryKeyConstraint("id", name=op.f("pk_pubsub_subs")), | |
35 sa.UniqueConstraint("node_id", "subscriber", name=op.f("uq_pubsub_subs_node_id")), | |
29 ) | 36 ) |
30 | 37 |
31 | 38 |
32 def downgrade(): | 39 def downgrade(): |
33 op.drop_table('pubsub_subs') | 40 op.drop_table("pubsub_subs") |