refactoring: renamed sat package to libervia.backend

This commit is contained in:
Goffi 2023-06-02 11:49:51 +02:00
commit d2685ba11b
11 changed files with 1293 additions and 1293 deletions

View file

@ -0,0 +1,3 @@
This directory and subdirectories contains Alembic migration scripts.
Please check Libervia documentation for details.

View file

@ -0,0 +1,89 @@
# A generic, single database configuration.
[alembic]
# path to migration scripts
script_location = %(here)s
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s
# sys.path path, will be prepended to sys.path if present.
# defaults to the current working directory.
# prepend_sys_path = .
# timezone to use when rendering the date
# within the migration file as well as the filename.
# string value is passed to dateutil.tz.gettz()
# leave blank for localtime
# timezone =
# max length of characters to apply to the
# "slug" field
# truncate_slug_length = 40
# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false
# set to 'true' to allow .pyc and .pyo files without
# a source .py file to be detected as revisions in the
# versions/ directory
# sourceless = false
# version location specification; this defaults
# to migration/versions. When using multiple version
# directories, initial revisions must be specified with --version-path
# version_locations = %(here)s/bar %(here)s/bat migration/versions
# the output encoding used when revision files
# are written from script.py.mako
# output_encoding = utf-8
# sqlalchemy.url = driver://user:pass@localhost/dbname
[post_write_hooks]
# post_write_hooks defines scripts or Python functions that are run
# on newly generated revision scripts. See the documentation for further
# detail and examples
# format using "black" - use the console_scripts runner, against the "black" entrypoint
# hooks = black
# black.type = console_scripts
# black.entrypoint = black
# black.options = -l 79 REVISION_SCRIPT_FILENAME
# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARN
handlers = console
qualname =
[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine
[logger_alembic]
level = INFO
handlers =
qualname = alembic
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S

View file

@ -0,0 +1,93 @@
import asyncio
from logging.config import fileConfig
from sqlalchemy import pool
from sqlalchemy.ext.asyncio import create_async_engine
from alembic import context
from libervia.backend.memory import sqla_config
from libervia.backend.memory.sqla_mapping import Base
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
target_metadata = Base.metadata
# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.
def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
"""
db_config = sqla_config.get_db_config()
context.configure(
url=db_config["url"],
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={"paramstyle": "named"},
)
with context.begin_transaction():
context.run_migrations()
def include_name(name, type_, parent_names):
if type_ == "table":
if name.startswith("pubsub_items_fts"):
return False
return True
def do_run_migrations(connection):
context.configure(
connection=connection,
target_metadata=target_metadata,
render_as_batch=True,
include_name=include_name
)
with context.begin_transaction():
context.run_migrations()
async def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
db_config = sqla_config.get_db_config()
engine = create_async_engine(
db_config["url"],
poolclass=pool.NullPool,
future=True,
)
async with engine.connect() as connection:
await connection.run_sync(do_run_migrations)
if context.is_offline_mode():
run_migrations_offline()
else:
asyncio.run(run_migrations_online())

View file

@ -0,0 +1,24 @@
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}
"""
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
# revision identifiers, used by Alembic.
revision = ${repr(up_revision)}
down_revision = ${repr(down_revision)}
branch_labels = ${repr(branch_labels)}
depends_on = ${repr(depends_on)}
def upgrade():
${upgrades if upgrades else "pass"}
def downgrade():
${downgrades if downgrades else "pass"}

View file

@ -0,0 +1,49 @@
"""create virtual table for Full-Text Search
Revision ID: 129ac51807e4
Revises: 8974efc51d22
Create Date: 2021-08-13 19:13:54.112538
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '129ac51807e4'
down_revision = '8974efc51d22'
branch_labels = None
depends_on = None
def upgrade():
queries = [
"CREATE VIRTUAL TABLE pubsub_items_fts "
"USING fts5(data, content=pubsub_items, content_rowid=id)",
"CREATE TRIGGER pubsub_items_fts_sync_ins AFTER INSERT ON pubsub_items BEGIN"
" INSERT INTO pubsub_items_fts(rowid, data) VALUES (new.id, new.data);"
"END",
"CREATE TRIGGER pubsub_items_fts_sync_del AFTER DELETE ON pubsub_items BEGIN"
" INSERT INTO pubsub_items_fts(pubsub_items_fts, rowid, data) "
"VALUES('delete', old.id, old.data);"
"END",
"CREATE TRIGGER pubsub_items_fts_sync_upd AFTER UPDATE ON pubsub_items BEGIN"
" INSERT INTO pubsub_items_fts(pubsub_items_fts, rowid, data) VALUES"
"('delete', old.id, old.data);"
" INSERT INTO pubsub_items_fts(rowid, data) VALUES(new.id, new.data);"
"END",
"INSERT INTO pubsub_items_fts(rowid, data) SELECT id, data from pubsub_items"
]
for q in queries:
op.execute(sa.DDL(q))
def downgrade():
queries = [
"DROP TRIGGER IF EXISTS pubsub_items_fts_sync_ins",
"DROP TRIGGER IF EXISTS pubsub_items_fts_sync_del",
"DROP TRIGGER IF EXISTS pubsub_items_fts_sync_upd",
"DROP TABLE IF EXISTS pubsub_items_fts",
]
for q in queries:
op.execute(sa.DDL(q))

View file

@ -0,0 +1,60 @@
"""add origin_id column to history and adapt constraints
Revision ID: 4b002773cf92
Revises: 79e5f3313fa4
Create Date: 2022-06-13 16:10:39.711634
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '4b002773cf92'
down_revision = '79e5f3313fa4'
branch_labels = None
depends_on = None
def upgrade():
with op.batch_alter_table('history', schema=None) as batch_op:
batch_op.add_column(sa.Column('origin_id', sa.Text(), nullable=True))
batch_op.create_unique_constraint('uq_origin_id', ['profile_id', 'origin_id', 'source'])
with op.batch_alter_table('message', schema=None) as batch_op:
batch_op.alter_column('history_uid',
existing_type=sa.TEXT(),
nullable=False)
batch_op.alter_column('message',
existing_type=sa.TEXT(),
nullable=False)
with op.batch_alter_table('subject', schema=None) as batch_op:
batch_op.alter_column('history_uid',
existing_type=sa.TEXT(),
nullable=False)
batch_op.alter_column('subject',
existing_type=sa.TEXT(),
nullable=False)
def downgrade():
with op.batch_alter_table('subject', schema=None) as batch_op:
batch_op.alter_column('subject',
existing_type=sa.TEXT(),
nullable=True)
batch_op.alter_column('history_uid',
existing_type=sa.TEXT(),
nullable=True)
with op.batch_alter_table('message', schema=None) as batch_op:
batch_op.alter_column('message',
existing_type=sa.TEXT(),
nullable=True)
batch_op.alter_column('history_uid',
existing_type=sa.TEXT(),
nullable=True)
with op.batch_alter_table('history', schema=None) as batch_op:
batch_op.drop_constraint('uq_origin_id', type_='unique')
batch_op.drop_column('origin_id')

View file

@ -0,0 +1,410 @@
"""drop message_types table + fix nullable + rename constraints
Revision ID: 602caf848068
Revises:
Create Date: 2021-06-26 12:42:54.148313
"""
from alembic import op
from sqlalchemy import (
Table,
Column,
MetaData,
TEXT,
INTEGER,
Text,
Integer,
Float,
Enum,
ForeignKey,
Index,
PrimaryKeyConstraint,
)
from sqlalchemy.sql import table, column
# revision identifiers, used by Alembic.
revision = "602caf848068"
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# we have to recreate former tables for batch_alter_table's reflexion, otherwise the
# database will be used, and this will keep unammed UNIQUE constraints in addition
# to the named ones that we create
metadata = MetaData(
naming_convention={
"ix": "ix_%(column_0_label)s",
"uq": "uq_%(table_name)s_%(column_0_name)s",
"ck": "ck_%(table_name)s_%(constraint_name)s",
"fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
"pk": "pk_%(table_name)s",
},
)
old_profiles_table = Table(
"profiles",
metadata,
Column("id", Integer, primary_key=True, nullable=True, autoincrement=False),
Column("name", Text, unique=True),
)
old_components_table = Table(
"components",
metadata,
Column(
"profile_id",
ForeignKey("profiles.id", ondelete="CASCADE"),
nullable=True,
primary_key=True,
),
Column("entry_point", Text, nullable=False),
)
old_message_table = Table(
"message",
metadata,
Column("id", Integer, primary_key=True, nullable=True, autoincrement=False),
Column("history_uid", ForeignKey("history.uid", ondelete="CASCADE")),
Column("message", Text),
Column("language", Text),
Index("message__history_uid", "history_uid"),
)
old_subject_table = Table(
"subject",
metadata,
Column("id", Integer, primary_key=True, nullable=True, autoincrement=False),
Column("history_uid", ForeignKey("history.uid", ondelete="CASCADE")),
Column("subject", Text),
Column("language", Text),
Index("subject__history_uid", "history_uid"),
)
old_thread_table = Table(
"thread",
metadata,
Column("id", Integer, primary_key=True, nullable=True, autoincrement=False),
Column("history_uid", ForeignKey("history.uid", ondelete="CASCADE")),
Column("thread_id", Text),
Column("parent_id", Text),
Index("thread__history_uid", "history_uid"),
)
old_history_table = Table(
"history",
metadata,
Column("uid", Text, primary_key=True, nullable=True),
Column("stanza_id", Text),
Column("update_uid", Text),
Column("profile_id", Integer, ForeignKey("profiles.id", ondelete="CASCADE")),
Column("source", Text),
Column("dest", Text),
Column("source_res", Text),
Column("dest_res", Text),
Column("timestamp", Float, nullable=False),
Column("received_timestamp", Float),
Column("type", Text, ForeignKey("message_types.type")),
Column("extra", Text),
Index("history__profile_id_timestamp", "profile_id", "timestamp"),
Index(
"history__profile_id_received_timestamp", "profile_id", "received_timestamp"
),
)
old_param_gen_table = Table(
"param_gen",
metadata,
Column("category", Text, primary_key=True),
Column("name", Text, primary_key=True),
Column("value", Text),
)
old_param_ind_table = Table(
"param_ind",
metadata,
Column("category", Text, primary_key=True),
Column("name", Text, primary_key=True),
Column(
"profile_id", ForeignKey("profiles.id", ondelete="CASCADE"), primary_key=True
),
Column("value", Text),
)
old_private_gen_table = Table(
"private_gen",
metadata,
Column("namespace", Text, primary_key=True),
Column("key", Text, primary_key=True),
Column("value", Text),
)
old_private_ind_table = Table(
"private_ind",
metadata,
Column("namespace", Text, primary_key=True),
Column("key", Text, primary_key=True),
Column(
"profile_id", ForeignKey("profiles.id", ondelete="CASCADE"), primary_key=True
),
Column("value", Text),
)
old_private_gen_bin_table = Table(
"private_gen_bin",
metadata,
Column("namespace", Text, primary_key=True),
Column("key", Text, primary_key=True),
Column("value", Text),
)
old_private_ind_bin_table = Table(
"private_ind_bin",
metadata,
Column("namespace", Text, primary_key=True),
Column("key", Text, primary_key=True),
Column(
"profile_id", ForeignKey("profiles.id", ondelete="CASCADE"), primary_key=True
),
Column("value", Text),
)
old_files_table = Table(
"files",
metadata,
Column("id", Text, primary_key=True),
Column("public_id", Text, unique=True),
Column("version", Text, primary_key=True),
Column("parent", Text, nullable=False),
Column(
"type",
Enum("file", "directory", name="file_type", create_constraint=True),
nullable=False,
server_default="file",
),
Column("file_hash", Text),
Column("hash_algo", Text),
Column("name", Text, nullable=False),
Column("size", Integer),
Column("namespace", Text),
Column("media_type", Text),
Column("media_subtype", Text),
Column("created", Float, nullable=False),
Column("modified", Float),
Column("owner", Text),
Column("access", Text),
Column("extra", Text),
Column("profile_id", ForeignKey("profiles.id", ondelete="CASCADE")),
Index("files__profile_id_owner_parent", "profile_id", "owner", "parent"),
Index(
"files__profile_id_owner_media_type_media_subtype",
"profile_id",
"owner",
"media_type",
"media_subtype",
),
)
op.drop_table("message_types")
with op.batch_alter_table(
"profiles", copy_from=old_profiles_table, schema=None
) as batch_op:
batch_op.create_unique_constraint(batch_op.f("uq_profiles_name"), ["name"])
with op.batch_alter_table(
"components",
copy_from=old_components_table,
naming_convention={
"fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
},
schema=None,
) as batch_op:
batch_op.create_unique_constraint(batch_op.f("uq_profiles_name"), ["name"])
with op.batch_alter_table(
"history",
copy_from=old_history_table,
naming_convention={
"fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
},
schema=None,
) as batch_op:
batch_op.alter_column("uid", existing_type=TEXT(), nullable=False)
batch_op.alter_column(
"type",
type_=Enum(
"chat",
"error",
"groupchat",
"headline",
"normal",
"info",
name="message_type",
create_constraint=True,
),
existing_type=TEXT(),
nullable=False,
)
batch_op.create_unique_constraint(
batch_op.f("uq_history_profile_id"),
["profile_id", "stanza_id", "source", "dest"],
)
batch_op.drop_constraint("fk_history_type_message_types", type_="foreignkey")
with op.batch_alter_table(
"message", copy_from=old_message_table, schema=None
) as batch_op:
batch_op.alter_column(
"id", existing_type=INTEGER(), nullable=False, autoincrement=False
)
with op.batch_alter_table(
"subject", copy_from=old_subject_table, schema=None
) as batch_op:
batch_op.alter_column(
"id", existing_type=INTEGER(), nullable=False, autoincrement=False
)
with op.batch_alter_table(
"thread", copy_from=old_thread_table, schema=None
) as batch_op:
batch_op.alter_column(
"id", existing_type=INTEGER(), nullable=False, autoincrement=False
)
with op.batch_alter_table(
"param_gen", copy_from=old_param_gen_table, schema=None
) as batch_op:
batch_op.alter_column("category", existing_type=TEXT(), nullable=False)
batch_op.alter_column("name", existing_type=TEXT(), nullable=False)
with op.batch_alter_table(
"param_ind", copy_from=old_param_ind_table, schema=None
) as batch_op:
batch_op.alter_column("category", existing_type=TEXT(), nullable=False)
batch_op.alter_column("name", existing_type=TEXT(), nullable=False)
batch_op.alter_column("profile_id", existing_type=INTEGER(), nullable=False)
with op.batch_alter_table(
"private_gen", copy_from=old_private_gen_table, schema=None
) as batch_op:
batch_op.alter_column("namespace", existing_type=TEXT(), nullable=False)
batch_op.alter_column("key", existing_type=TEXT(), nullable=False)
with op.batch_alter_table(
"private_ind", copy_from=old_private_ind_table, schema=None
) as batch_op:
batch_op.alter_column("namespace", existing_type=TEXT(), nullable=False)
batch_op.alter_column("key", existing_type=TEXT(), nullable=False)
batch_op.alter_column("profile_id", existing_type=INTEGER(), nullable=False)
with op.batch_alter_table(
"private_gen_bin", copy_from=old_private_gen_bin_table, schema=None
) as batch_op:
batch_op.alter_column("namespace", existing_type=TEXT(), nullable=False)
batch_op.alter_column("key", existing_type=TEXT(), nullable=False)
# found some invalid rows in local database, maybe old values made during development,
# but in doubt we have to delete them
op.execute("DELETE FROM private_ind_bin WHERE namespace IS NULL")
with op.batch_alter_table(
"private_ind_bin", copy_from=old_private_ind_bin_table, schema=None
) as batch_op:
batch_op.alter_column("namespace", existing_type=TEXT(), nullable=False)
batch_op.alter_column("key", existing_type=TEXT(), nullable=False)
batch_op.alter_column("profile_id", existing_type=INTEGER(), nullable=False)
with op.batch_alter_table(
"files", copy_from=old_files_table, schema=None
) as batch_op:
batch_op.create_unique_constraint(batch_op.f("uq_files_public_id"), ["public_id"])
batch_op.alter_column(
"type",
type_=Enum("file", "directory", name="file_type", create_constraint=True),
existing_type=Text(),
nullable=False,
)
def downgrade():
# downgrade doesn't restore the exact same state as before upgrade, as it
# would be useless and waste of resource to restore broken things such as
# anonymous constraints
with op.batch_alter_table("thread", schema=None) as batch_op:
batch_op.alter_column(
"id", existing_type=INTEGER(), nullable=True, autoincrement=False
)
with op.batch_alter_table("subject", schema=None) as batch_op:
batch_op.alter_column(
"id", existing_type=INTEGER(), nullable=True, autoincrement=False
)
with op.batch_alter_table("private_ind_bin", schema=None) as batch_op:
batch_op.alter_column("profile_id", existing_type=INTEGER(), nullable=True)
batch_op.alter_column("key", existing_type=TEXT(), nullable=True)
batch_op.alter_column("namespace", existing_type=TEXT(), nullable=True)
with op.batch_alter_table("private_ind", schema=None) as batch_op:
batch_op.alter_column("profile_id", existing_type=INTEGER(), nullable=True)
batch_op.alter_column("key", existing_type=TEXT(), nullable=True)
batch_op.alter_column("namespace", existing_type=TEXT(), nullable=True)
with op.batch_alter_table("private_gen_bin", schema=None) as batch_op:
batch_op.alter_column("key", existing_type=TEXT(), nullable=True)
batch_op.alter_column("namespace", existing_type=TEXT(), nullable=True)
with op.batch_alter_table("private_gen", schema=None) as batch_op:
batch_op.alter_column("key", existing_type=TEXT(), nullable=True)
batch_op.alter_column("namespace", existing_type=TEXT(), nullable=True)
with op.batch_alter_table("param_ind", schema=None) as batch_op:
batch_op.alter_column("profile_id", existing_type=INTEGER(), nullable=True)
batch_op.alter_column("name", existing_type=TEXT(), nullable=True)
batch_op.alter_column("category", existing_type=TEXT(), nullable=True)
with op.batch_alter_table("param_gen", schema=None) as batch_op:
batch_op.alter_column("name", existing_type=TEXT(), nullable=True)
batch_op.alter_column("category", existing_type=TEXT(), nullable=True)
with op.batch_alter_table("message", schema=None) as batch_op:
batch_op.alter_column(
"id", existing_type=INTEGER(), nullable=True, autoincrement=False
)
op.create_table(
"message_types",
Column("type", TEXT(), nullable=True),
PrimaryKeyConstraint("type"),
)
message_types_table = table("message_types", column("type", TEXT()))
op.bulk_insert(
message_types_table,
[
{"type": "chat"},
{"type": "error"},
{"type": "groupchat"},
{"type": "headline"},
{"type": "normal"},
{"type": "info"},
],
)
with op.batch_alter_table("history", schema=None) as batch_op:
batch_op.alter_column(
"type",
type_=TEXT(),
existing_type=TEXT(),
nullable=True,
)
batch_op.create_foreign_key(
batch_op.f("fk_history_type_message_types"),
"message_types",
["type"],
["type"],
)
batch_op.alter_column("uid", existing_type=TEXT(), nullable=True)

View file

@ -0,0 +1,33 @@
"""create table for pubsub subscriptions
Revision ID: 79e5f3313fa4
Revises: 129ac51807e4
Create Date: 2022-03-14 17:15:00.689871
"""
from alembic import op
import sqlalchemy as sa
from libervia.backend.memory.sqla_mapping import JID
# revision identifiers, used by Alembic.
revision = '79e5f3313fa4'
down_revision = '129ac51807e4'
branch_labels = None
depends_on = None
def upgrade():
op.create_table('pubsub_subs',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('node_id', sa.Integer(), nullable=False),
sa.Column('subscriber', JID(), nullable=True),
sa.Column('state', sa.Enum('SUBSCRIBED', 'PENDING', name='state'), nullable=True),
sa.ForeignKeyConstraint(['node_id'], ['pubsub_nodes.id'], name=op.f('fk_pubsub_subs_node_id_pubsub_nodes'), ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id', name=op.f('pk_pubsub_subs')),
sa.UniqueConstraint('node_id', 'subscriber', name=op.f('uq_pubsub_subs_node_id'))
)
def downgrade():
op.drop_table('pubsub_subs')

View file

@ -0,0 +1,57 @@
"""create tables for Pubsub caching
Revision ID: 8974efc51d22
Revises: 602caf848068
Create Date: 2021-07-27 16:38:54.658212
"""
from alembic import op
import sqlalchemy as sa
from libervia.backend.memory.sqla_mapping import JID, Xml
# revision identifiers, used by Alembic.
revision = '8974efc51d22'
down_revision = '602caf848068'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('pubsub_nodes',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('profile_id', sa.Integer(), nullable=True),
sa.Column('service', JID(), nullable=True),
sa.Column('name', sa.Text(), nullable=False),
sa.Column('subscribed', sa.Boolean(create_constraint=True, name='subscribed_bool'), nullable=False),
sa.Column('analyser', sa.Text(), nullable=True),
sa.Column('sync_state', sa.Enum('IN_PROGRESS', 'COMPLETED', 'ERROR', 'NO_SYNC', name='sync_state', create_constraint=True), nullable=True),
sa.Column('sync_state_updated', sa.Float(), nullable=False),
sa.Column('type', sa.Text(), nullable=True),
sa.Column('subtype', sa.Text(), nullable=True),
sa.Column('extra', sa.JSON(), nullable=True),
sa.ForeignKeyConstraint(['profile_id'], ['profiles.id'], name=op.f('fk_pubsub_nodes_profile_id_profiles'), ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id', name=op.f('pk_pubsub_nodes')),
sa.UniqueConstraint('profile_id', 'service', 'name', name=op.f('uq_pubsub_nodes_profile_id'))
)
op.create_table('pubsub_items',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('node_id', sa.Integer(), nullable=False),
sa.Column('name', sa.Text(), nullable=False),
sa.Column('data', Xml(), nullable=False),
sa.Column('created', sa.DateTime(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
sa.Column('updated', sa.DateTime(), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
sa.Column('parsed', sa.JSON(), nullable=True),
sa.ForeignKeyConstraint(['node_id'], ['pubsub_nodes.id'], name=op.f('fk_pubsub_items_node_id_pubsub_nodes'), ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id', name=op.f('pk_pubsub_items')),
sa.UniqueConstraint('node_id', 'name', name=op.f('uq_pubsub_items_node_id'))
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('pubsub_items')
op.drop_table('pubsub_nodes')
# ### end Alembic commands ###