Mercurial > libervia-backend
comparison libervia/backend/memory/migration/versions/8974efc51d22_create_tables_for_pubsub_caching.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: 8974efc51d22 | 3 Revision ID: 8974efc51d22 |
4 Revises: 602caf848068 | 4 Revises: 602caf848068 |
5 Create Date: 2021-07-27 16:38:54.658212 | 5 Create Date: 2021-07-27 16:38:54.658212 |
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, Xml | 11 from libervia.backend.memory.sqla_mapping import JID, Xml |
11 | 12 |
12 | 13 |
13 # revision identifiers, used by Alembic. | 14 # revision identifiers, used by Alembic. |
14 revision = '8974efc51d22' | 15 revision = "8974efc51d22" |
15 down_revision = '602caf848068' | 16 down_revision = "602caf848068" |
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 # ### commands auto generated by Alembic - please adjust! ### | 22 # ### commands auto generated by Alembic - please adjust! ### |
22 op.create_table('pubsub_nodes', | 23 op.create_table( |
23 sa.Column('id', sa.Integer(), nullable=False), | 24 "pubsub_nodes", |
24 sa.Column('profile_id', sa.Integer(), nullable=True), | 25 sa.Column("id", sa.Integer(), nullable=False), |
25 sa.Column('service', JID(), nullable=True), | 26 sa.Column("profile_id", sa.Integer(), nullable=True), |
26 sa.Column('name', sa.Text(), nullable=False), | 27 sa.Column("service", JID(), nullable=True), |
27 sa.Column('subscribed', sa.Boolean(create_constraint=True, name='subscribed_bool'), nullable=False), | 28 sa.Column("name", sa.Text(), nullable=False), |
28 sa.Column('analyser', sa.Text(), nullable=True), | 29 sa.Column( |
29 sa.Column('sync_state', sa.Enum('IN_PROGRESS', 'COMPLETED', 'ERROR', 'NO_SYNC', name='sync_state', create_constraint=True), nullable=True), | 30 "subscribed", |
30 sa.Column('sync_state_updated', sa.Float(), nullable=False), | 31 sa.Boolean(create_constraint=True, name="subscribed_bool"), |
31 sa.Column('type', sa.Text(), nullable=True), | 32 nullable=False, |
32 sa.Column('subtype', sa.Text(), nullable=True), | 33 ), |
33 sa.Column('extra', sa.JSON(), nullable=True), | 34 sa.Column("analyser", sa.Text(), nullable=True), |
34 sa.ForeignKeyConstraint(['profile_id'], ['profiles.id'], name=op.f('fk_pubsub_nodes_profile_id_profiles'), ondelete='CASCADE'), | 35 sa.Column( |
35 sa.PrimaryKeyConstraint('id', name=op.f('pk_pubsub_nodes')), | 36 "sync_state", |
36 sa.UniqueConstraint('profile_id', 'service', 'name', name=op.f('uq_pubsub_nodes_profile_id')) | 37 sa.Enum( |
38 "IN_PROGRESS", | |
39 "COMPLETED", | |
40 "ERROR", | |
41 "NO_SYNC", | |
42 name="sync_state", | |
43 create_constraint=True, | |
44 ), | |
45 nullable=True, | |
46 ), | |
47 sa.Column("sync_state_updated", sa.Float(), nullable=False), | |
48 sa.Column("type", sa.Text(), nullable=True), | |
49 sa.Column("subtype", sa.Text(), nullable=True), | |
50 sa.Column("extra", sa.JSON(), nullable=True), | |
51 sa.ForeignKeyConstraint( | |
52 ["profile_id"], | |
53 ["profiles.id"], | |
54 name=op.f("fk_pubsub_nodes_profile_id_profiles"), | |
55 ondelete="CASCADE", | |
56 ), | |
57 sa.PrimaryKeyConstraint("id", name=op.f("pk_pubsub_nodes")), | |
58 sa.UniqueConstraint( | |
59 "profile_id", "service", "name", name=op.f("uq_pubsub_nodes_profile_id") | |
60 ), | |
37 ) | 61 ) |
38 op.create_table('pubsub_items', | 62 op.create_table( |
39 sa.Column('id', sa.Integer(), nullable=False), | 63 "pubsub_items", |
40 sa.Column('node_id', sa.Integer(), nullable=False), | 64 sa.Column("id", sa.Integer(), nullable=False), |
41 sa.Column('name', sa.Text(), nullable=False), | 65 sa.Column("node_id", sa.Integer(), nullable=False), |
42 sa.Column('data', Xml(), nullable=False), | 66 sa.Column("name", sa.Text(), nullable=False), |
43 sa.Column('created', sa.DateTime(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), | 67 sa.Column("data", Xml(), nullable=False), |
44 sa.Column('updated', sa.DateTime(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), | 68 sa.Column( |
45 sa.Column('parsed', sa.JSON(), nullable=True), | 69 "created", |
46 sa.ForeignKeyConstraint(['node_id'], ['pubsub_nodes.id'], name=op.f('fk_pubsub_items_node_id_pubsub_nodes'), ondelete='CASCADE'), | 70 sa.DateTime(), |
47 sa.PrimaryKeyConstraint('id', name=op.f('pk_pubsub_items')), | 71 server_default=sa.text("(CURRENT_TIMESTAMP)"), |
48 sa.UniqueConstraint('node_id', 'name', name=op.f('uq_pubsub_items_node_id')) | 72 nullable=False, |
73 ), | |
74 sa.Column( | |
75 "updated", | |
76 sa.DateTime(), | |
77 server_default=sa.text("(CURRENT_TIMESTAMP)"), | |
78 nullable=False, | |
79 ), | |
80 sa.Column("parsed", sa.JSON(), nullable=True), | |
81 sa.ForeignKeyConstraint( | |
82 ["node_id"], | |
83 ["pubsub_nodes.id"], | |
84 name=op.f("fk_pubsub_items_node_id_pubsub_nodes"), | |
85 ondelete="CASCADE", | |
86 ), | |
87 sa.PrimaryKeyConstraint("id", name=op.f("pk_pubsub_items")), | |
88 sa.UniqueConstraint("node_id", "name", name=op.f("uq_pubsub_items_node_id")), | |
49 ) | 89 ) |
50 # ### end Alembic commands ### | 90 # ### end Alembic commands ### |
51 | 91 |
52 | 92 |
53 def downgrade(): | 93 def downgrade(): |
54 # ### commands auto generated by Alembic - please adjust! ### | 94 # ### commands auto generated by Alembic - please adjust! ### |
55 op.drop_table('pubsub_items') | 95 op.drop_table("pubsub_items") |
56 op.drop_table('pubsub_nodes') | 96 op.drop_table("pubsub_nodes") |
57 # ### end Alembic commands ### | 97 # ### end Alembic commands ### |