Python sqlalchemy.PickleType() Examples

The following are 30 code examples of sqlalchemy.PickleType(). 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 , or try the search function .
Example #1
Source File: 20bcb4b2673c_.py    From gitlab-tools with GNU General Public License v3.0 6 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('task_result',
    sa.Column('updated', sa.DateTime(), nullable=True),
    sa.Column('created', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('pull_mirror_id', sa.Integer(), nullable=True),
    sa.Column('push_mirror_id', sa.Integer(), nullable=True),
    sa.Column('task_id', sa.String(length=155), nullable=True),
    sa.Column('status', sa.String(length=50), nullable=True),
    sa.Column('task_name', sa.String(length=255), nullable=True),
    sa.Column('invoked_by', sa.Integer(), nullable=True),
    sa.Column('result', sa.PickleType(), nullable=True),
    sa.Column('date_done', sa.DateTime(), nullable=True),
    sa.Column('traceback', sa.Text(), nullable=True),
    sa.ForeignKeyConstraint(['pull_mirror_id'], ['pull_mirror.id'], ),
    sa.ForeignKeyConstraint(['push_mirror_id'], ['push_mirror.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('task_id')
    )
    op.create_index(op.f('ix_task_result_pull_mirror_id'), 'task_result', ['pull_mirror_id'], unique=False)
    op.create_index(op.f('ix_task_result_push_mirror_id'), 'task_result', ['push_mirror_id'], unique=False)
    # ### end Alembic commands ### 
Example #2
Source File: test_types.py    From sqlalchemy with MIT License 6 votes vote down vote up
def test_custom_pickle(self):
        class MyPickleType(types.TypeDecorator):
            impl = PickleType

            def process_bind_param(self, value, dialect):
                if value:
                    value.stuff = "BIND" + value.stuff
                return value

            def process_result_value(self, value, dialect):
                if value:
                    value.stuff = value.stuff + "RESULT"
                return value

        data = pickleable.Foo("im foo 1")
        expected = pickleable.Foo("im foo 1")
        expected.stuff = "BINDim stuffRESULT"

        self._test_round_trip(MyPickleType, data, expected=expected) 
Example #3
Source File: 37e242787ae5_opendaylight_neutron_mechanism_driver_.py    From networking-odl with Apache License 2.0 6 votes vote down vote up
def upgrade():
    op.create_table(
        'opendaylightjournal',
        sa.Column('id', sa.String(36), primary_key=True),
        sa.Column('object_type', sa.String(36), nullable=False),
        sa.Column('object_uuid', sa.String(36), nullable=False),
        sa.Column('operation', sa.String(36), nullable=False),
        sa.Column('data', sa.PickleType, nullable=True),
        sa.Column('state',
                  sa.Enum('pending', 'processing', 'failed', 'completed',
                          name='state'),
                  nullable=False, default='pending'),
        sa.Column('retry_count', sa.Integer, default=0),
        sa.Column('created_at', sa.DateTime, default=sa.func.now()),
        sa.Column('last_retried', sa.TIMESTAMP, server_default=sa.func.now(),
                  onupdate=sa.func.now())
    ) 
Example #4
Source File: 3d560427d776_add_sequence_number_to_journal.py    From networking-odl with Apache License 2.0 6 votes vote down vote up
def upgrade():
    op.create_table(
        'opendaylightjournal_new',
        sa.Column('seqnum', sa.BigInteger(),
                  primary_key=True, autoincrement=True),
        sa.Column('object_type', sa.String(36), nullable=False),
        sa.Column('object_uuid', sa.String(36), nullable=False),
        sa.Column('operation', sa.String(36), nullable=False),
        sa.Column('data', sa.PickleType, nullable=True),
        sa.Column('state',
                  sa.Enum('pending', 'processing', 'failed', 'completed',
                          name='state'),
                  nullable=False, default='pending'),
        sa.Column('retry_count', sa.Integer, default=0),
        sa.Column('created_at', sa.DateTime, default=sa.func.now()),
        sa.Column('last_retried', sa.TIMESTAMP, server_default=sa.func.now(),
                  onupdate=sa.func.now()),
    ) 
Example #5
Source File: test_types.py    From sqlalchemy with MIT License 6 votes vote down vote up
def test_eq_comparison(self):
        p1 = PickleType()

        for obj in (
            {"1": "2"},
            pickleable.Bar(5, 6),
            pickleable.OldSchool(10, 11),
        ):
            assert p1.compare_values(p1.copy_value(obj), obj)

        assert_raises(
            NotImplementedError,
            p1.compare_values,
            pickleable.BrokenComparable("foo"),
            pickleable.BrokenComparable("foo"),
        ) 
Example #6
Source File: test_types.py    From sqlalchemy with MIT License 5 votes vote down vote up
def setup_class(cls):
        global binary_table, MyPickleType, metadata

        class MyPickleType(types.TypeDecorator):
            impl = PickleType

            def process_bind_param(self, value, dialect):
                if value:
                    value.stuff = "this is modified stuff"
                return value

            def process_result_value(self, value, dialect):
                if value:
                    value.stuff = "this is the right stuff"
                return value

        metadata = MetaData(testing.db)
        binary_table = Table(
            "binary_table",
            metadata,
            Column(
                "primary_id",
                Integer,
                primary_key=True,
                test_needs_autoincrement=True,
            ),
            Column("data", LargeBinary),
            Column("data_slice", LargeBinary(100)),
            Column("misc", String(30)),
            Column("pickled", PickleType),
            Column("mypickle", MyPickleType),
        )
        metadata.create_all() 
Example #7
Source File: test_types.py    From sqlalchemy with MIT License 5 votes vote down vote up
def test_plain_pickle(self):
        self._test_round_trip(PickleType, pickleable.Foo("im foo 1")) 
Example #8
Source File: 5246a6bd410f_multisite_vim.py    From tacker with Apache License 2.0 5 votes vote down vote up
def upgrade(active_plugins=None, options=None):
    op.create_table('vims',
        sa.Column('id', sa.String(length=255), nullable=False),
        sa.Column('type', sa.String(length=255), nullable=False),
        sa.Column('tenant_id', sa.String(length=255), nullable=True),
        sa.Column('name', sa.String(length=255), nullable=True),
        sa.Column('description', sa.String(length=255), nullable=True),
        sa.Column('placement_attr', sa.PickleType(), nullable=True),
        sa.Column('shared', sa.Boolean(), server_default=sa.text(u'true'),
                  nullable=False),
        sa.PrimaryKeyConstraint('id'),
        mysql_engine='InnoDB'
    )
    op.create_table('vimauths',
        sa.Column('id', sa.String(length=36), nullable=False),
        sa.Column('vim_id', sa.String(length=255), nullable=False),
        sa.Column('password', sa.String(length=128), nullable=False),
        sa.Column('auth_url', sa.String(length=255), nullable=False),
        sa.Column('vim_project', sa.PickleType(), nullable=False),
        sa.Column('auth_cred', sa.PickleType(), nullable=False),
        sa.ForeignKeyConstraint(['vim_id'], ['vims.id'], ),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('auth_url')
    )
    op.add_column(u'devices', sa.Column('placement_attr', sa.PickleType(),
                                        nullable=True))
    op.add_column(u'devices', sa.Column('vim_id', sa.String(length=36),
                                        nullable=False))
    op.create_foreign_key(None, 'devices', 'vims', ['vim_id'], ['id']) 
Example #9
Source File: sqla.py    From malwareHunter with GNU General Public License v2.0 5 votes vote down vote up
def make_cache_table(metadata, table_name='beaker_cache', schema_name=None):
    """Return a ``Table`` object suitable for storing cached values for the
    namespace manager.  Do not create the table."""
    return sa.Table(table_name, metadata,
                    sa.Column('namespace', sa.String(255), primary_key=True),
                    sa.Column('accessed', sa.DateTime, nullable=False),
                    sa.Column('created', sa.DateTime, nullable=False),
                    sa.Column('data', sa.PickleType, nullable=False),
                    schema=schema_name if schema_name else metadata.schema) 
Example #10
Source File: sqla.py    From malwareHunter with GNU General Public License v2.0 5 votes vote down vote up
def make_cache_table(metadata, table_name='beaker_cache', schema_name=None):
    """Return a ``Table`` object suitable for storing cached values for the
    namespace manager.  Do not create the table."""
    return sa.Table(table_name, metadata,
                    sa.Column('namespace', sa.String(255), primary_key=True),
                    sa.Column('accessed', sa.DateTime, nullable=False),
                    sa.Column('created', sa.DateTime, nullable=False),
                    sa.Column('data', sa.PickleType, nullable=False),
                    schema=schema_name if schema_name else metadata.schema) 
Example #11
Source File: c7652b2a97a4_4_3_to_4_4.py    From cloudify-manager with Apache License 2.0 5 votes vote down vote up
def upgrade():
    # server_default accepts string or SQL element only
    op.add_column('secrets', sa.Column('is_hidden_value',
                                       sa.Boolean(),
                                       nullable=False,
                                       server_default='f'))
    op.add_column('deployment_updates', sa.Column('_old_blueprint_fk',
                                                  sa.Integer(),
                                                  nullable=True))
    op.add_column('deployment_updates', sa.Column('_new_blueprint_fk',
                                                  sa.Integer(),
                                                  nullable=True))
    op.add_column('deployment_updates', sa.Column('old_inputs',
                                                  sa.PickleType(),
                                                  nullable=True))
    op.add_column('deployment_updates', sa.Column('new_inputs',
                                                  sa.PickleType(),
                                                  nullable=True))
    op.add_column('users', sa.Column('last_failed_login_at',
                                     UTCDateTime(),
                                     nullable=True))
    op.add_column('users', sa.Column('failed_logins_counter',
                                     sa.Integer(),
                                     nullable=False,
                                     server_default="0"))
    op.add_column('executions', sa.Column('ended_at',
                                          UTCDateTime(),
                                          nullable=True))
    op.execute('COMMIT')
    op.execute("alter type execution_status add value 'kill_cancelling'") 
Example #12
Source File: test_merge.py    From sqlalchemy with MIT License 5 votes vote down vote up
def define_tables(cls, metadata):
        Table(
            "data",
            metadata,
            Column(
                "id", Integer, primary_key=True, test_needs_autoincrement=True
            ),
            Column("data", PickleType(comparator=operator.eq)),
        ) 
Example #13
Source File: sqla.py    From bazarr with GNU General Public License v3.0 5 votes vote down vote up
def make_cache_table(metadata, table_name='beaker_cache', schema_name=None):
    """Return a ``Table`` object suitable for storing cached values for the
    namespace manager.  Do not create the table."""
    return sa.Table(table_name, metadata,
                    sa.Column('namespace', sa.String(255), primary_key=True),
                    sa.Column('accessed', sa.DateTime, nullable=False),
                    sa.Column('created', sa.DateTime, nullable=False),
                    sa.Column('data', sa.PickleType, nullable=False),
                    schema=schema_name if schema_name else metadata.schema) 
Example #14
Source File: 4280bf2417c_.py    From evesrp with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def downgrade():
    # Add ship and pilot transformer columns back to division
    op.add_column('division', sa.Column('ship_transformer', sa.PickleType))
    op.add_column('division', sa.Column('pilot_transformer', sa.PickleType))
    # Convert transformerrefs back to the old columns
    conn = op.get_bind()
    columns = [
        transformerref.c.division_id,
        transformerref.c.attribute_name,
        transformerref.c.transformer,
    ]
    transformer_sel = select(columns)\
            .where(or_(
                    transformerref.c.attribute_name == 'ship_type',
                    transformerref.c.attribute_name == 'pilot',
            ))
    transformer_rows = conn.execute(transformer_sel)
    for division_id, attribute_name, transformer in transformer_rows:
        if attribute_name == 'ship_type':
            colname = 'ship'
            transformer_class = evesrp.transformers.ShipTransformer
        elif attribute_name == 'pilot':
            colname = 'pilot'
            transformer_class = evesrp.transformers.PilotTransformer
        colname += '_transformer'
        transformer = transformer_class(transformer.name, transformer.slug)
        update_stmt = update(division)\
                .where(division.c.id == division_id)\
                .values({
                        colname: transformer
                })
        conn.execute(update_stmt)
    transformer_rows.close()
    # Drop the transformerref table. This is going to be lossy.
    op.drop_table('transformerref') 
Example #15
Source File: d4841aeeb072_.py    From gitlab-tools 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('celery_taskmeta',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('task_id', sa.String(length=155), nullable=True),
    sa.Column('status', sa.String(length=50), nullable=True),
    sa.Column('result', sa.PickleType(), nullable=True),
    sa.Column('date_done', sa.DateTime(), nullable=True),
    sa.Column('traceback', sa.Text(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('task_id'),
    sqlite_autoincrement=True
    )
    op.create_table('celery_tasksetmeta',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('taskset_id', sa.String(length=155), nullable=True),
    sa.Column('result', sa.PickleType(), nullable=True),
    sa.Column('date_done', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('taskset_id'),
    sqlite_autoincrement=True
    )
    op.add_column('task_result', sa.Column('celery_taskmeta_id', sa.Integer(), nullable=False))
    op.create_index(op.f('ix_task_result_celery_taskmeta_id'), 'task_result', ['celery_taskmeta_id'], unique=False)
    op.drop_constraint('task_result_task_id_key', 'task_result', type_='unique')
    op.create_foreign_key(None, 'task_result', 'celery_taskmeta', ['celery_taskmeta_id'], ['id'])
    op.drop_column('task_result', 'result')
    op.drop_column('task_result', 'status')
    op.drop_column('task_result', 'date_done')
    op.drop_column('task_result', 'task_id')
    op.drop_column('task_result', 'traceback')
    # ### end Alembic commands ### 
Example #16
Source File: c1fc69b629_.py    From evesrp with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def upgrade():
    op.add_column('division',
            sa.Column('pilot_transformer', sa.PickleType(), nullable=True))
    op.add_column('division',
            sa.Column('ship_transformer', sa.PickleType(), nullable=True))
    op.drop_column('request', 'ship_url') 
Example #17
Source File: dc1beda6749e_add_tables_for_task_results.py    From packit-service with MIT License 5 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "task_results",
        sa.Column("task_id", sa.String(), nullable=False),
        sa.Column("jobs", sa.PickleType(), nullable=True),
        sa.Column("event", sa.PickleType(), nullable=True),
        sa.PrimaryKeyConstraint("task_id"),
    )
    op.drop_column("copr_builds", "logs")
    # ### end Alembic commands ### 
Example #18
Source File: create_database.py    From estimagic with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _define_scalar_pickle_table(database, name):
    dash_options = Table(
        name, database, Column("value", PickleType), extend_existing=True
    )
    return dash_options 
Example #19
Source File: create_database.py    From estimagic with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _define_one_column_pickle_table(database, table):
    params_table = Table(
        table,
        database,
        Column("iteration", Integer, primary_key=True),
        Column("value", PickleType),
        sqlite_autoincrement=True,
        extend_existing=True,
    )
    return params_table 
Example #20
Source File: create_database.py    From estimagic with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _define_start_params_table(database):
    start_params_table = Table(
        "start_params", database, Column("value", PickleType), extend_existing=True
    )
    return start_params_table 
Example #21
Source File: bdaa763e6c56_make_xcom_value_column_a_large_binary.py    From airflow with Apache License 2.0 5 votes vote down vote up
def downgrade():   # noqa: D103
    # use batch_alter_table to support SQLite workaround
    with op.batch_alter_table("xcom") as batch_op:
        batch_op.alter_column('value', type_=sa.PickleType(pickler=dill)) 
Example #22
Source File: 27c6a30d7c24_add_executor_config_to_task_instance.py    From airflow with Apache License 2.0 5 votes vote down vote up
def upgrade():   # noqa: D103
    op.add_column(TASK_INSTANCE_TABLE, sa.Column(NEW_COLUMN, sa.PickleType(pickler=dill))) 
Example #23
Source File: 40e67319e3a9_dagrun_config.py    From airflow with Apache License 2.0 5 votes vote down vote up
def upgrade():   # noqa: D103
    op.add_column('dag_run', sa.Column('conf', sa.PickleType(), nullable=True)) 
Example #24
Source File: 4d9cf7d32f2_insert_headers.py    From octavia with Apache License 2.0 5 votes vote down vote up
def upgrade():
    op.add_column('listener', sa.Column('insert_headers', sa.PickleType())) 
Example #25
Source File: test_types.py    From sqlalchemy with MIT License 4 votes vote down vote up
def test_round_trip(self, connection):
        testobj1 = pickleable.Foo("im foo 1")
        testobj2 = pickleable.Foo("im foo 2")
        testobj3 = pickleable.Foo("im foo 3")

        stream1 = self.load_stream("binary_data_one.dat")
        stream2 = self.load_stream("binary_data_two.dat")
        connection.execute(
            binary_table.insert(),
            primary_id=1,
            misc="binary_data_one.dat",
            data=stream1,
            data_slice=stream1[0:100],
            pickled=testobj1,
            mypickle=testobj3,
        )
        connection.execute(
            binary_table.insert(),
            primary_id=2,
            misc="binary_data_two.dat",
            data=stream2,
            data_slice=stream2[0:99],
            pickled=testobj2,
        )
        connection.execute(
            binary_table.insert(),
            primary_id=3,
            misc="binary_data_two.dat",
            data=None,
            data_slice=stream2[0:99],
            pickled=None,
        )

        for stmt in (
            binary_table.select(order_by=binary_table.c.primary_id),
            text(
                "select * from binary_table order by binary_table.primary_id",
                bind=testing.db,
            ).columns(
                **{
                    "pickled": PickleType,
                    "mypickle": MyPickleType,
                    "data": LargeBinary,
                    "data_slice": LargeBinary,
                }
            ),
        ):
            result = connection.execute(stmt).fetchall()
            eq_(stream1, result[0]._mapping["data"])
            eq_(stream1[0:100], result[0]._mapping["data_slice"])
            eq_(stream2, result[1]._mapping["data"])
            eq_(testobj1, result[0]._mapping["pickled"])
            eq_(testobj2, result[1]._mapping["pickled"])
            eq_(testobj3.moredata, result[0]._mapping["mypickle"].moredata)
            eq_(
                result[0]._mapping["mypickle"].stuff, "this is the right stuff"
            ) 
Example #26
Source File: ee69294e63e_init_state.py    From flask-project-template with MIT License 4 votes vote down vote up
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('social_auth_code',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('email', sa.String(length=200), nullable=True),
    sa.Column('code', sa.String(length=32), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('code', 'email')
    )
    op.create_index(op.f('ix_social_auth_code_code'), 'social_auth_code', ['code'], unique=False)
    op.create_table('social_auth_nonce',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('server_url', sa.String(length=255), nullable=True),
    sa.Column('timestamp', sa.Integer(), nullable=True),
    sa.Column('salt', sa.String(length=40), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('server_url', 'timestamp', 'salt')
    )
    op.create_table('social_auth_association',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('server_url', sa.String(length=255), nullable=True),
    sa.Column('handle', sa.String(length=255), nullable=True),
    sa.Column('secret', sa.String(length=255), nullable=True),
    sa.Column('issued', sa.Integer(), nullable=True),
    sa.Column('lifetime', sa.Integer(), nullable=True),
    sa.Column('assoc_type', sa.String(length=64), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('server_url', 'handle')
    )
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('username', sa.String(length=200), nullable=True),
    sa.Column('password', sa.String(length=200), nullable=True),
    sa.Column('name', sa.String(length=100), nullable=True),
    sa.Column('email', sa.String(length=200), nullable=True),
    sa.Column('active', sa.Boolean(), nullable=True),
    sa.Column('ui_lang', sa.String(length=2), nullable=True),
    sa.Column('url', sa.String(length=200), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('username')
    )
    op.create_table('social_auth_usersocialauth',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('provider', sa.String(length=32), nullable=True),
    sa.Column('uid', sa.String(length=255), nullable=True),
    sa.Column('extra_data', sa.PickleType(), nullable=True),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], [u'users.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('provider', 'uid')
    )
    op.create_index(op.f('ix_social_auth_usersocialauth_user_id'), 'social_auth_usersocialauth', ['user_id'], unique=False)
    ### end Alembic commands ### 
Example #27
Source File: dff56c93da8d_add_matrix_nio_state_store_to_main_db.py    From mautrix-telegram with GNU Affero General Public License v3.0 4 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('nio_account',
    sa.Column('user_id', sa.String(length=255), nullable=False),
    sa.Column('device_id', sa.String(length=255), nullable=False),
    sa.Column('shared', sa.Boolean(), nullable=False),
    sa.Column('sync_token', sa.Text(), nullable=False),
    sa.Column('account', sa.LargeBinary(), nullable=False),
    sa.PrimaryKeyConstraint('user_id', 'device_id')
    )
    op.create_table('nio_device_key',
    sa.Column('user_id', sa.String(length=255), nullable=False),
    sa.Column('device_id', sa.String(length=255), nullable=False),
    sa.Column('display_name', sa.String(length=255), nullable=False),
    sa.Column('deleted', sa.Boolean(), nullable=False),
    sa.Column('keys', sa.PickleType(), nullable=False),
    sa.PrimaryKeyConstraint('user_id', 'device_id')
    )
    op.create_table('nio_megolm_inbound_session',
    sa.Column('session_id', sa.String(length=255), nullable=False),
    sa.Column('sender_key', sa.String(length=255), nullable=False),
    sa.Column('fp_key', sa.String(length=255), nullable=False),
    sa.Column('room_id', sa.String(length=255), nullable=False),
    sa.Column('session', sa.LargeBinary(), nullable=False),
    sa.Column('forwarded_chains', sa.PickleType(), nullable=False),
    sa.PrimaryKeyConstraint('session_id')
    )
    op.create_table('nio_olm_session',
    sa.Column('session_id', sa.String(length=255), nullable=False),
    sa.Column('sender_key', sa.String(length=255), nullable=False),
    sa.Column('session', sa.LargeBinary(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('last_used', sa.DateTime(), nullable=False),
    sa.PrimaryKeyConstraint('session_id')
    )
    op.create_table('nio_outgoing_key_request',
    sa.Column('request_id', sa.String(length=255), nullable=False),
    sa.Column('session_id', sa.String(length=255), nullable=False),
    sa.Column('room_id', sa.String(length=255), nullable=False),
    sa.Column('algorithm', sa.String(length=255), nullable=False),
    sa.PrimaryKeyConstraint('request_id')
    )
    # ### end Alembic commands ### 
Example #28
Source File: c36b294b1f5f_initial_revision.py    From mautrix-facebook with GNU Affero General Public License v3.0 4 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('message',
    sa.Column('mxid', sa.String(length=255), nullable=True),
    sa.Column('mx_room', sa.String(length=255), nullable=True),
    sa.Column('fbid', sa.String(length=127), nullable=False),
    sa.Column('index', sa.SmallInteger(), nullable=False),
    sa.PrimaryKeyConstraint('fbid', 'index'),
    sa.UniqueConstraint('mxid', 'mx_room', name='_mx_id_room')
    )
    op.create_table('mx_room_state',
    sa.Column('room_id', sa.String(length=255), nullable=False),
    sa.Column('power_levels', PowerLevelType(), nullable=True),
    sa.PrimaryKeyConstraint('room_id')
    )
    op.create_table('mx_user_profile',
    sa.Column('room_id', sa.String(length=255), nullable=False),
    sa.Column('user_id', sa.String(length=255), nullable=False),
    sa.Column('membership', sa.Enum('JOIN', 'LEAVE', 'INVITE', 'BAN', 'KNOCK', name='membership'), nullable=False),
    sa.Column('displayname', sa.String(), nullable=True),
    sa.Column('avatar_url', sa.String(length=255), nullable=True),
    sa.PrimaryKeyConstraint('room_id', 'user_id')
    )
    op.create_table('portal',
    sa.Column('fbid', sa.String(length=127), nullable=False),
    sa.Column('fb_receiver', sa.String(length=127), nullable=False),
    sa.Column('fb_type', sa.Enum('USER', 'GROUP', 'ROOM', 'PAGE', name='threadtype'), nullable=False),
    sa.Column('mxid', sa.String(length=255), nullable=True),
    sa.Column('name', sa.String(), nullable=True),
    sa.Column('photo_id', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('fbid', 'fb_receiver'),
    sa.UniqueConstraint('mxid')
    )
    op.create_table('puppet',
    sa.Column('fbid', sa.String(), nullable=False),
    sa.Column('name', sa.String(), nullable=True),
    sa.Column('photo_id', sa.String(), nullable=True),
    sa.Column('matrix_registered', sa.Boolean(), server_default=sa.text('false'), nullable=False),
    sa.PrimaryKeyConstraint('fbid')
    )
    op.create_table('user',
    sa.Column('mxid', sa.String(length=255), nullable=False),
    sa.Column('session', sa.PickleType(), nullable=True),
    sa.Column('fbid', sa.String(length=255), nullable=True),
    sa.PrimaryKeyConstraint('mxid')
    )
    # ### end Alembic commands ### 
Example #29
Source File: c56c9a30b228_add_end_to_bridge_encryption_fields.py    From mautrix-facebook with GNU Affero General Public License v3.0 4 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('nio_account',
    sa.Column('user_id', sa.String(length=255), nullable=False),
    sa.Column('device_id', sa.String(length=255), nullable=False),
    sa.Column('shared', sa.Boolean(), nullable=False),
    sa.Column('sync_token', sa.Text(), nullable=False),
    sa.Column('account', sa.LargeBinary(), nullable=False),
    sa.PrimaryKeyConstraint('user_id', 'device_id')
    )
    op.create_table('nio_device_key',
    sa.Column('user_id', sa.String(length=255), nullable=False),
    sa.Column('device_id', sa.String(length=255), nullable=False),
    sa.Column('display_name', sa.String(length=255), nullable=False),
    sa.Column('deleted', sa.Boolean(), nullable=False),
    sa.Column('keys', sa.PickleType(), nullable=False),
    sa.PrimaryKeyConstraint('user_id', 'device_id')
    )
    op.create_table('nio_megolm_inbound_session',
    sa.Column('session_id', sa.String(length=255), nullable=False),
    sa.Column('sender_key', sa.String(length=255), nullable=False),
    sa.Column('fp_key', sa.String(length=255), nullable=False),
    sa.Column('room_id', sa.String(length=255), nullable=False),
    sa.Column('session', sa.LargeBinary(), nullable=False),
    sa.Column('forwarded_chains', sa.PickleType(), nullable=False),
    sa.PrimaryKeyConstraint('session_id')
    )
    op.create_table('nio_olm_session',
    sa.Column('session_id', sa.String(length=255), nullable=False),
    sa.Column('sender_key', sa.String(length=255), nullable=False),
    sa.Column('session', sa.LargeBinary(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('last_used', sa.DateTime(), nullable=False),
    sa.PrimaryKeyConstraint('session_id')
    )
    op.create_table('nio_outgoing_key_request',
    sa.Column('request_id', sa.String(length=255), nullable=False),
    sa.Column('session_id', sa.String(length=255), nullable=False),
    sa.Column('room_id', sa.String(length=255), nullable=False),
    sa.Column('algorithm', sa.String(length=255), nullable=False),
    sa.PrimaryKeyConstraint('request_id')
    )
    with op.batch_alter_table('portal') as batch_op:
        batch_op.add_column(sa.Column('encrypted', sa.Boolean(), server_default=sa.false(), nullable=False))
    # ### end Alembic commands ### 
Example #30
Source File: c319c2ce8698_add_end_to_bridge_encryption_fields.py    From mautrix-hangouts with GNU Affero General Public License v3.0 4 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('nio_account',
    sa.Column('user_id', sa.String(length=255), nullable=False),
    sa.Column('device_id', sa.String(length=255), nullable=False),
    sa.Column('shared', sa.Boolean(), nullable=False),
    sa.Column('sync_token', sa.Text(), nullable=False),
    sa.Column('account', sa.LargeBinary(), nullable=False),
    sa.PrimaryKeyConstraint('user_id', 'device_id')
    )
    op.create_table('nio_device_key',
    sa.Column('user_id', sa.String(length=255), nullable=False),
    sa.Column('device_id', sa.String(length=255), nullable=False),
    sa.Column('display_name', sa.String(length=255), nullable=False),
    sa.Column('deleted', sa.Boolean(), nullable=False),
    sa.Column('keys', sa.PickleType(), nullable=False),
    sa.PrimaryKeyConstraint('user_id', 'device_id')
    )
    op.create_table('nio_megolm_inbound_session',
    sa.Column('session_id', sa.String(length=255), nullable=False),
    sa.Column('sender_key', sa.String(length=255), nullable=False),
    sa.Column('fp_key', sa.String(length=255), nullable=False),
    sa.Column('room_id', sa.String(length=255), nullable=False),
    sa.Column('session', sa.LargeBinary(), nullable=False),
    sa.Column('forwarded_chains', sa.PickleType(), nullable=False),
    sa.PrimaryKeyConstraint('session_id')
    )
    op.create_table('nio_olm_session',
    sa.Column('session_id', sa.String(length=255), nullable=False),
    sa.Column('sender_key', sa.String(length=255), nullable=False),
    sa.Column('session', sa.LargeBinary(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('last_used', sa.DateTime(), nullable=False),
    sa.PrimaryKeyConstraint('session_id')
    )
    op.create_table('nio_outgoing_key_request',
    sa.Column('request_id', sa.String(length=255), nullable=False),
    sa.Column('session_id', sa.String(length=255), nullable=False),
    sa.Column('room_id', sa.String(length=255), nullable=False),
    sa.Column('algorithm', sa.String(length=255), nullable=False),
    sa.PrimaryKeyConstraint('request_id')
    )
    with op.batch_alter_table('portal') as batch_op:
        batch_op.add_column(sa.Column('encrypted', sa.Boolean(), server_default=sa.false(), nullable=False))
    # ### end Alembic commands ###