Python sqlalchemy.dialects.postgresql.JSON Examples

The following are 30 code examples of sqlalchemy.dialects.postgresql.JSON(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module sqlalchemy.dialects.postgresql , or try the search function .
Example #1
Source File: test_indexable.py    From sqlalchemy with MIT License 6 votes vote down vote up
def test_get_default_value(self):
        Base = declarative_base()

        class J(Base):
            __tablename__ = "j"
            id = Column(Integer, primary_key=True)
            json = Column(JSON, default={})
            default = index_property("json", "field", default="default")
            none = index_property("json", "field", default=None)

        j = J()
        assert j.json is None

        assert j.default == "default"
        assert j.none is None
        j.json = {}
        assert j.default == "default"
        assert j.none is None
        j.default = None
        assert j.default is None
        assert j.none is None
        j.none = 10
        assert j.default == 10
        assert j.none == 10 
Example #2
Source File: test_indexable.py    From sqlalchemy with MIT License 6 votes vote down vote up
def test_json(self):
        Base = declarative_base()

        class J(Base):
            __tablename__ = "j"
            id = Column("id", Integer, primary_key=True)
            json = Column("_json", JSON, default={})
            field = index_property("json", "field")

        j = J(json={"a": 1, "b": 2})
        assert_raises(AttributeError, lambda: j.field)
        j.field = "test"
        eq_(j.field, "test")
        eq_(j.json, {"a": 1, "b": 2, "field": "test"})

        j2 = J(field="test")
        eq_(j2.json, {"field": "test"})
        eq_(j2.field, "test") 
Example #3
Source File: 0110_monthly_billing.py    From notifications-api with MIT License 6 votes vote down vote up
def upgrade():

    op.create_table('monthly_billing',
                    sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
                    sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=False),
                    sa.Column('month', sa.String(), nullable=False),
                    sa.Column('year', sa.Float(), nullable=False),
                    sa.Column('notification_type',
                              postgresql.ENUM('email', 'sms', 'letter', name='notification_type', create_type=False),
                              nullable=False),
                    sa.Column('monthly_totals', postgresql.JSON(), nullable=False),
                    sa.Column('updated_at', sa.DateTime, nullable=False),
                    sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
                    sa.PrimaryKeyConstraint('id')
                    )
    op.create_index(op.f('ix_monthly_billing_service_id'), 'monthly_billing', ['service_id'], unique=False)
    op.create_index(op.f('uix_monthly_billing'), 'monthly_billing', ['service_id', 'month', 'year', 'notification_type'], unique=True) 
Example #4
Source File: 0210_remove_monthly_billing.py    From notifications-api with MIT License 6 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('monthly_billing',
    sa.Column('id', postgresql.UUID(), autoincrement=False, nullable=False),
    sa.Column('service_id', postgresql.UUID(), autoincrement=False, nullable=False),
    sa.Column('notification_type', postgresql.ENUM('email', 'sms', 'letter', name='notification_type'), autoincrement=False, nullable=False),
    sa.Column('monthly_totals', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=False),
    sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
    sa.Column('start_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
    sa.Column('end_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
    sa.ForeignKeyConstraint(['service_id'], ['services.id'], name='monthly_billing_service_id_fkey'),
    sa.PrimaryKeyConstraint('id', name='monthly_billing_pkey'),
    sa.UniqueConstraint('service_id', 'start_date', 'notification_type', name='uix_monthly_billing')
    )
    op.create_index('ix_monthly_billing_service_id', 'monthly_billing', ['service_id'], unique=False)
    # ### end Alembic commands ### 
Example #5
Source File: 31850461ed3_.py    From puffin with GNU Affero General Public License v3.0 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('application_settings',
    sa.Column('application_settings_id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('application_id', sa.String(length=64), nullable=False),
    sa.Column('settings', postgresql.JSON(), nullable=False),
    sa.PrimaryKeyConstraint('application_settings_id')
    )
    op.create_index('idx_application_settings', 'application_settings', ['user_id', 'application_id'], unique=True)
    ### end Alembic commands ### 
Example #6
Source File: bag.py    From py-mongosql with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def _dot_notation(name: str) -> Tuple[str, List[str]]:
    """ Split a property name that's using dot-notation.

    This is used to navigate the internals of JSON types:

        "json_column.property.property"
    """
    path = name.split('.')
    return path[0], path[1:] 
Example #7
Source File: __init__.py    From sqlalchemy-aurora-data-api with Apache License 2.0 5 votes vote down vote up
def bind_expression(self, value):
        return cast(value, sqltypes.JSON) 
Example #8
Source File: test_contrib.py    From aiohttp_admin with Apache License 2.0 5 votes vote down vote up
def test_get_type_of_fields(resources):
    table = sa.Table(
        'Test', sa.MetaData(),
        sa.Column('integer', sa.Integer, primary_key=True),
        sa.Column('text', sa.Text),
        sa.Column('float', sa.Float),
        sa.Column('date', sa.Date),
        sa.Column('boolean', sa.Boolean),
        sa.Column('json', postgresql.JSON),
    )
    fields = ['integer', 'text', 'float', 'date', 'boolean', 'json', ]

    data_type_fields = resources.get_type_of_fields(fields, table)
    expected_type_fields = {
        'integer': rc.TEXT_FIELD.value,
        'text': rc.TEXT_FIELD.value,
        'float': rc.NUMBER_FIELD.value,
        'date': rc.DATE_FIELD.value,
        'boolean': rc.BOOLEAN_FIELD.value,
        'json': rc.JSON_FIELD.value,
    }

    assert data_type_fields == expected_type_fields

    fields = None
    data_type_fields = resources.get_type_of_fields(fields, table)
    expected_type_fields = {
        'integer': rc.TEXT_FIELD.value,
    }

    assert data_type_fields == expected_type_fields


# TODO: added Mongo 
Example #9
Source File: test_sa_validator.py    From aiohttp_admin with Apache License 2.0 5 votes vote down vote up
def table():

    meta = sa.MetaData()
    post = sa.Table(
        'post', meta,
        sa.Column('id', sa.Integer, nullable=False),
        sa.Column('title', sa.String(200), nullable=False),
        sa.Column('body', sa.Text, nullable=False),
        sa.Column('views', sa.Integer, nullable=False),
        sa.Column('average_note', sa.Float, nullable=False),
        sa.Column('pictures', postgresql.JSON, server_default='{}'),
        sa.Column('published_at', sa.Date, nullable=False),
        sa.Column('tags', postgresql.ARRAY(sa.Integer), server_default='[]'),

        # Indexes #
        sa.PrimaryKeyConstraint('id', name='post_id_pkey'))
    return post 
Example #10
Source File: test_postgresql.py    From alembic with MIT License 5 votes vote down vote up
def test_json_type(self):
        eq_ignore_whitespace(
            autogenerate.render._repr_type(JSON(), self.autogen_context),
            "postgresql.JSON(astext_type=sa.Text())",
        ) 
Example #11
Source File: 0010_events_table.py    From notifications-api with MIT License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('events',
    sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
    sa.Column('event_type', sa.String(length=255), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('data', postgresql.JSON(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    ### end Alembic commands ### 
Example #12
Source File: test_converter.py    From graphene-sqlalchemy with MIT License 5 votes vote down vote up
def test_should_postgresql_json_convert():
    assert get_field(postgresql.JSON()).type == graphene.JSONString 
Example #13
Source File: query_builder.py    From sqlalchemy-json-api with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def select_related(self, obj, relationship_key, **kwargs):
        """
        Builds a query for selecting related resource(s). This method can be
        used for building select queries for JSON requests such as::

            GET articles/1/author

        Usage::

            article = session.query(Article).get(1)

            query = query_builder.select_related(
                article,
                'category'
            )

        :param obj:
            The root object to select the related resources from.
        :param fields:
            A mapping of fields. Keys representing model keys and values as
            lists of model descriptor names.
        :param include:
            List of dot-separated relationship paths.
        :param links:
            A dictionary of links to apply as top level links in the built
            query. Keys representing json keys and values as valid urls or
            dictionaries.
        :param sort:
            List of attributes to apply as an order by for the root model.
        :param from_obj:
            A SQLAlchemy selectable (for example a Query object) to select the
            query results from.
        :param as_text:
            Whether or not to build a query that returns the results as text
            (raw json).

        .. versionadded: 0.2
        """
        return self._select_related(obj, relationship_key, **kwargs) 
Example #14
Source File: 8acbad111ef6_queue_table_for_pq.py    From pygameweb with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('queue',
    sa.Column('id', sa.BIGINT(), nullable=False),
    sa.Column('enqueued_at', postgresql.TIMESTAMP(timezone=True), server_default=sa.text('now()'), autoincrement=False, nullable=False),
    sa.Column('dequeued_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True),
    sa.Column('expected_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True),
    sa.Column('schedule_at', postgresql.TIMESTAMP(timezone=True), autoincrement=False, nullable=True),
    sa.Column('q_name', sa.TEXT(), autoincrement=False, nullable=False),
    sa.Column('data', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('priority_idx', 'queue', ['schedule_at', 'expected_at'], unique=False)
    # ### end Alembic commands ### 
Example #15
Source File: sa_utils.py    From aiohttp_admin with Apache License 2.0 5 votes vote down vote up
def build_trafaret(sa_type, **kwargs):

    if isinstance(sa_type, sa.sql.sqltypes.Enum):
        trafaret = t.Enum(*sa_type.enums, **kwargs)

    # check for Text should be before String
    elif isinstance(sa_type, sa.sql.sqltypes.Text):
        trafaret = t.String(**kwargs)

    elif isinstance(sa_type, sa.sql.sqltypes.String):
        trafaret = t.String(max_length=sa_type.length, **kwargs)

    elif isinstance(sa_type, sa.sql.sqltypes.Integer):
        trafaret = t.ToInt(**kwargs)

    elif isinstance(sa_type, sa.sql.sqltypes.Float):
        trafaret = t.ToFloat(**kwargs)

    elif isinstance(sa_type, sa.sql.sqltypes.DateTime):
        trafaret = DateTime(**kwargs)  # RFC3339

    elif isinstance(sa_type, sa.sql.sqltypes.Date):
        trafaret = DateTime(**kwargs)  # RFC3339

    elif isinstance(sa_type, sa.sql.sqltypes.Boolean):
        trafaret = t.ToBool(**kwargs)

    # Add PG related JSON and ARRAY
    elif isinstance(sa_type, postgresql.JSON):
        trafaret = AnyDict | t.List(AnyDict)

    # Add PG related JSON and ARRAY
    elif isinstance(sa_type, postgresql.ARRAY):
        item_trafaret = build_trafaret(sa_type.item_type)
        trafaret = t.List(item_trafaret)

    else:
        type_ = str(sa_type)
        msg = 'Validator for type {} not implemented'.format(type_)
        raise NotImplementedError(msg)
    return trafaret 
Example #16
Source File: base_tasks.py    From bigmetadata with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def run(self):
        json_colnames = []
        table = '.'.join([self.schema, self.table])
        if table in metadata.tables:
            cols = metadata.tables[table].columns
            for colname, coldef in list(cols.items()):
                coltype = coldef.type
                if isinstance(coltype, JSON):
                    json_colnames.append(colname)

        sql_to_cartodb_table(self.output().tablename, self.table, json_colnames,
                             schema=self.schema)
        self.force = False 
Example #17
Source File: test_types.py    From sqlalchemy with MIT License 5 votes vote down vote up
def setup(self):
        metadata = MetaData()
        self.test_table = Table(
            "test_table",
            metadata,
            Column("id", Integer, primary_key=True),
            Column("test_column", JSON),
        )
        self.jsoncol = self.test_table.c.test_column 
Example #18
Source File: test_types.py    From sqlalchemy with MIT License 5 votes vote down vote up
def test_path_typing(self):
        col = column("x", JSON())
        is_(col["q"].type._type_affinity, types.JSON)
        is_(col[("q",)].type._type_affinity, types.JSON)
        is_(col["q"]["p"].type._type_affinity, types.JSON)
        is_(col[("q", "p")].type._type_affinity, types.JSON) 
Example #19
Source File: test_types.py    From sqlalchemy with MIT License 5 votes vote down vote up
def test_custom_astext_type(self):
        class MyType(types.UserDefinedType):
            pass

        col = column("x", JSON(astext_type=MyType))

        is_(col["q"].astext.type.__class__, MyType)

        is_(col[("q", "p")].astext.type.__class__, MyType)

        is_(col["q"]["p"].astext.type.__class__, MyType) 
Example #20
Source File: test_types.py    From sqlalchemy with MIT License 5 votes vote down vote up
def _test_insert_nulljson_into_none_as_null(self, engine):
        with engine.connect() as conn:
            conn.execute(
                self.tables.data_table.insert(),
                {"name": "r1", "nulldata": JSON.NULL},
            )
            self._assert_column_is_JSON_NULL(conn, column="nulldata") 
Example #21
Source File: test_indexable.py    From sqlalchemy with MIT License 5 votes vote down vote up
def setup_classes(cls):
        from sqlalchemy.dialects.postgresql import JSON

        Base = cls.DeclarativeBasic

        class json_property(index_property):
            def __init__(self, attr_name, index, cast_type):
                super(json_property, self).__init__(attr_name, index)
                self.cast_type = cast_type

            def expr(self, model):
                expr = super(json_property, self).expr(model)
                return expr.astext.cast(self.cast_type)

        class Json(fixtures.ComparableEntity, Base):
            __tablename__ = "json"

            id = Column(
                sa.Integer, primary_key=True, test_needs_autoincrement=True
            )
            json = Column(JSON, default={})
            field = index_property("json", "field")
            json_field = index_property("json", "field")
            int_field = json_property("json", "field", Integer)
            text_field = json_property("json", "field", Text)
            other = index_property("json", "other")
            subfield = json_property("other", "field", Text) 
Example #22
Source File: compressed_json_type.py    From uszipcode-project with MIT License 5 votes vote down vote up
def load_dialect_impl(self, dialect):
        if dialect.name == 'postgresql':
            # Use the native JSON type.
            if has_postgres_json:
                return dialect.type_descriptor(JSON())
            else:
                return dialect.type_descriptor(PostgresJSONType())
        else:
            return dialect.type_descriptor(self.impl) 
Example #23
Source File: 159ba85908fd_add_contributed_values_table.py    From QCFractal with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():

    # rename old column with data
    op.alter_column("dataset", "contributed_values", new_column_name="contributed_values_data")
    op.alter_column("reaction_dataset", "contributed_values", new_column_name="contributed_values_data")

    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "contributed_values",
        sa.Column("name", sa.String(), nullable=False),
        sa.Column("collection_id", sa.Integer(), nullable=False),
        sa.Column("citations", sa.JSON(), nullable=True),
        sa.Column("theory_level", sa.JSON(), nullable=False),
        sa.Column("theory_level_details", sa.JSON(), nullable=True),
        sa.Column("comments", sa.String(), nullable=True),
        sa.Column("values", MsgpackExt(), nullable=False),
        sa.Column("index", MsgpackExt(), nullable=False),
        sa.Column("external_url", sa.String(), nullable=True),
        sa.Column("doi", sa.String(), nullable=True),
        sa.Column("units", sa.String(), nullable=False),
        sa.Column("values_structure", sa.JSON(), nullable=True, default=lambda: {}),
        sa.ForeignKeyConstraint(["collection_id"], ["collection.id"], ondelete="cascade"),
        sa.PrimaryKeyConstraint("name", "collection_id"),
    )

    op.alter_column("contributed_values", "values_structure", server_default=None, nullable=False)

    migrate_contributed_values_data()

    op.drop_column("dataset", "contributed_values_data")
    op.drop_column("reaction_dataset", "contributed_values_data") 
Example #24
Source File: 159ba85908fd_add_contributed_values_table.py    From QCFractal with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def downgrade():
    # ### Won't work on production data because data will be lost ###

    op.add_column(
        "reaction_dataset",
        sa.Column("contributed_values", postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    )
    op.add_column(
        "dataset",
        sa.Column("contributed_values", postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    )
    op.drop_table("contributed_values") 
Example #25
Source File: af906681b8b2_.py    From SempoBlockchain with GNU General Public License v3.0 5 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('ussd_sessions', sa.Column('sessions_data', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True))
    op.drop_column('ussd_sessions', 'session_data')
    # ### end Alembic commands ### 
Example #26
Source File: __init__.py    From sqlalchemy-aurora-data-api with Apache License 2.0 5 votes vote down vote up
def bind_expression(self, value):
        return cast(value, JSON) 
Example #27
Source File: 00033_53fab90468f4_.py    From ReadableWebProxy with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('feed_post_meta',
    sa.Column('id', sa.BigInteger(), nullable=False),
    sa.Column('contentid', sa.Text(), nullable=False),
    sa.Column('meta', JSON(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_feed_post_meta_contentid'), 'feed_post_meta', ['contentid'], unique=True)
    ### end Alembic commands ### 
Example #28
Source File: 47c9e8260c4d_.py    From SempoBlockchain with GNU General Public License v3.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('user', sa.Column('matched_profile_pictures', postgresql.JSON(astext_type=sa.Text()), nullable=True))
    # ### end Alembic commands ### 
Example #29
Source File: 5f4b4c9f586d_.py    From SempoBlockchain with GNU General Public License v3.0 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('ussd_menu',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('authorising_user_id', sa.Integer(), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('updated', sa.DateTime(), nullable=True),
    sa.Column('name', sa.String(), nullable=False),
    sa.Column('description', sa.String(), nullable=True),
    sa.Column('parent_id', sa.Integer(), nullable=True),
    sa.Column('display_key', sa.String(), nullable=False),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_ussd_menu_name'), 'ussd_menu', ['name'], unique=True)
    op.create_table('ussd_session',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('authorising_user_id', sa.Integer(), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('updated', sa.DateTime(), nullable=True),
    sa.Column('session_id', sa.String(), nullable=False),
    sa.Column('service_code', sa.String(), nullable=False),
    sa.Column('msisdn', sa.String(), nullable=False),
    sa.Column('user_input', sa.String(), nullable=True),
    sa.Column('state', sa.String(), nullable=False),
    sa.Column('session_data', postgresql.JSON(astext_type=sa.Text()), nullable=True),
    sa.Column('ussd_menu_id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
    sa.ForeignKeyConstraint(['ussd_menu_id'], ['ussd_menu.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_ussd_session_session_id'), 'ussd_session', ['session_id'], unique=True)
    op.drop_index('ix_ussd_sessions_session_id', table_name='ussd_sessions')
    op.drop_table('ussd_sessions')
    op.drop_index('ix_ussd_menus_name', table_name='ussd_menus')
    op.drop_table('ussd_menus')
    # ### end Alembic commands ### 
Example #30
Source File: 5f4b4c9f586d_.py    From SempoBlockchain with GNU General Public License v3.0 5 votes vote down vote up
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('ussd_menus',
    sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
    sa.Column('authorising_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('updated', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=False),
    sa.Column('description', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('parent_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('display_key', sa.VARCHAR(), autoincrement=False, nullable=False),
    sa.PrimaryKeyConstraint('id', name='ussd_menus_pkey')
    )
    op.create_index('ix_ussd_menus_name', 'ussd_menus', ['name'], unique=True)
    op.create_table('ussd_sessions',
    sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
    sa.Column('authorising_user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('updated', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
    sa.Column('session_id', sa.VARCHAR(), autoincrement=False, nullable=False),
    sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True),
    sa.Column('service_code', sa.VARCHAR(), autoincrement=False, nullable=False),
    sa.Column('msisdn', sa.VARCHAR(), autoincrement=False, nullable=False),
    sa.Column('user_input', sa.VARCHAR(), autoincrement=False, nullable=True),
    sa.Column('ussd_menu_id', sa.INTEGER(), autoincrement=False, nullable=False),
    sa.Column('state', sa.VARCHAR(), autoincrement=False, nullable=False),
    sa.Column('session_data', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True),
    sa.PrimaryKeyConstraint('id', name='ussd_sessions_pkey')
    )
    op.create_index('ix_ussd_sessions_session_id', 'ussd_sessions', ['session_id'], unique=True)
    op.drop_index(op.f('ix_ussd_session_session_id'), table_name='ussd_session')
    op.drop_table('ussd_session')
    op.drop_index(op.f('ix_ussd_menu_name'), table_name='ussd_menu')
    op.drop_table('ussd_menu')
    # ### end Alembic commands ###