Ejemplo n.º 1
0
def downgrade():
    op.create_table(
        'lens',
        sa.Column('public_id', sa.BINARY(length=16), nullable=False),
        sa.Column('created_at', mysql.DATETIME(), nullable=False),
        sa.Column('updated_at', mysql.DATETIME(), nullable=False),
        sa.Column('deleted_at', mysql.DATETIME(), nullable=True),
        sa.Column('id', mysql.INTEGER(display_width=11), nullable=False),
        sa.Column('namespace_id', mysql.INTEGER(display_width=11),
                  autoincrement=False, nullable=False),
        sa.Column('subject', mysql.VARCHAR(length=255), nullable=True),
        sa.Column('thread_public_id', sa.BINARY(length=16), nullable=True),
        sa.Column('started_before', mysql.DATETIME(), nullable=True),
        sa.Column('started_after', mysql.DATETIME(), nullable=True),
        sa.Column('last_message_before', mysql.DATETIME(), nullable=True),
        sa.Column('last_message_after', mysql.DATETIME(), nullable=True),
        sa.Column('any_email', mysql.VARCHAR(length=255), nullable=True),
        sa.Column('to_addr', mysql.VARCHAR(length=255), nullable=True),
        sa.Column('from_addr', mysql.VARCHAR(length=255), nullable=True),
        sa.Column('cc_addr', mysql.VARCHAR(length=255), nullable=True),
        sa.Column('bcc_addr', mysql.VARCHAR(length=255), nullable=True),
        sa.Column('filename', mysql.VARCHAR(length=255), nullable=True),
        sa.Column('tag', mysql.VARCHAR(length=255), nullable=True),
        sa.ForeignKeyConstraint(['namespace_id'], [u'namespace.id'],
                                name=u'lens_ibfk_1', ondelete=u'CASCADE'),
        sa.PrimaryKeyConstraint('id'),
        mysql_default_charset=u'utf8mb4',
        mysql_engine=u'InnoDB'
    )
    op.create_table(
        'webhook',
        sa.Column('public_id', sa.BINARY(length=16), nullable=False),
        sa.Column('created_at', mysql.DATETIME(), nullable=False),
        sa.Column('updated_at', mysql.DATETIME(), nullable=False),
        sa.Column('deleted_at', mysql.DATETIME(), nullable=True),
        sa.Column('id', mysql.INTEGER(display_width=11), nullable=False),
        sa.Column('namespace_id', mysql.INTEGER(display_width=11),
                  autoincrement=False, nullable=False),
        sa.Column('lens_id', mysql.INTEGER(display_width=11),
                  autoincrement=False, nullable=False),
        sa.Column('callback_url', mysql.TEXT(), nullable=False),
        sa.Column('failure_notify_url', mysql.TEXT(), nullable=True),
        sa.Column('include_body', mysql.TINYINT(display_width=1),
                  autoincrement=False, nullable=False),
        sa.Column('max_retries', mysql.INTEGER(display_width=11),
                  server_default='3', autoincrement=False, nullable=False),
        sa.Column('retry_interval', mysql.INTEGER(display_width=11),
                  server_default='60', autoincrement=False, nullable=False),
        sa.Column('active', mysql.TINYINT(display_width=1), server_default='1',
                  autoincrement=False, nullable=False),
        sa.Column('min_processed_id', mysql.INTEGER(display_width=11),
                  server_default='0', autoincrement=False, nullable=False),
        sa.ForeignKeyConstraint(['lens_id'], [u'lens.id'],
                                name=u'webhook_ibfk_2', ondelete=u'CASCADE'),
        sa.ForeignKeyConstraint(['namespace_id'], [u'namespace.id'],
                                name=u'webhook_ibfk_1', ondelete=u'CASCADE'),
        sa.PrimaryKeyConstraint('id'),
        mysql_default_charset=u'utf8mb4',
        mysql_engine=u'InnoDB'
    )
Ejemplo n.º 2
0
def upgrade():
    from inbox.sqlalchemy_ext.util import JSON

    shard_id = int(context.get_x_argument(as_dictionary=True).get("shard_id"))
    namespace_id_type = sa.Integer() if shard_id == 0 else sa.BigInteger()

    op.create_table(
        "metadata",
        sa.Column("public_id", sa.BINARY(length=16), nullable=False),
        sa.Column("created_at", sa.DateTime(), nullable=False),
        sa.Column("updated_at", sa.DateTime(), nullable=False),
        sa.Column("deleted_at", sa.DateTime(), nullable=True),
        sa.Column("id", sa.BigInteger(), nullable=False),
        sa.Column("app_id", sa.Integer(), nullable=True),
        sa.Column("app_client_id", sa.BINARY(length=16), nullable=False),
        sa.Column("app_type", sa.String(length=20), nullable=False),
        sa.Column("namespace_id", namespace_id_type, nullable=False),
        sa.Column("object_public_id", sa.String(length=191), nullable=False),
        sa.Column("object_type", sa.String(length=20), nullable=False),
        sa.Column("object_id", sa.BigInteger(), nullable=False),
        sa.Column("value", JSON(), nullable=True),
        sa.Column("version", sa.Integer(), server_default="0", nullable=True),
        sa.ForeignKeyConstraint(["namespace_id"], [u"namespace.id"],
                                ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(op.f("ix_metadata_created_at"),
                    "metadata", ["created_at"],
                    unique=False)
    op.create_index(op.f("ix_metadata_deleted_at"),
                    "metadata", ["deleted_at"],
                    unique=False)
    op.create_index(op.f("ix_metadata_object_id"),
                    "metadata", ["object_id"],
                    unique=False)
    op.create_index(
        op.f("ix_metadata_object_public_id"),
        "metadata",
        ["object_public_id"],
        unique=False,
    )
    op.create_index(op.f("ix_metadata_public_id"),
                    "metadata", ["public_id"],
                    unique=False)
    op.create_index(op.f("ix_metadata_updated_at"),
                    "metadata", ["updated_at"],
                    unique=False)
    op.create_index(
        "ix_obj_public_id_app_id",
        "metadata",
        ["object_public_id", "app_id"],
        unique=True,
    )

    conn = op.get_bind()
    increment = (shard_id << 48) + 1
    conn.execute("ALTER TABLE metadata AUTO_INCREMENT={}".format(increment))
Ejemplo n.º 3
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'nyaa_trackerapi', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('info_hash', sa.BINARY(length=20), nullable=False),
        sa.Column('method', sa.String(length=255), nullable=False),
        sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'sukebei_trackerapi', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('info_hash', sa.BINARY(length=20), nullable=False),
        sa.Column('method', sa.String(length=255), nullable=False),
        sa.PrimaryKeyConstraint('id'))
def upgrade():
    from inbox.sqlalchemy_ext.util import JSON

    shard_id = int(context.get_x_argument(as_dictionary=True).get('shard_id'))
    namespace_id_type = sa.Integer() if shard_id == 0 else sa.BigInteger()

    op.create_table(
        'metadata', sa.Column('public_id',
                              sa.BINARY(length=16),
                              nullable=False),
        sa.Column('created_at', sa.DateTime(), nullable=False),
        sa.Column('updated_at', sa.DateTime(), nullable=False),
        sa.Column('deleted_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.BigInteger(), nullable=False),
        sa.Column('app_id', sa.Integer(), nullable=True),
        sa.Column('app_client_id', sa.BINARY(length=16), nullable=False),
        sa.Column('app_type', sa.String(length=20), nullable=False),
        sa.Column('namespace_id', namespace_id_type, nullable=False),
        sa.Column('object_public_id', sa.String(length=191), nullable=False),
        sa.Column('object_type', sa.String(length=20), nullable=False),
        sa.Column('object_id', sa.BigInteger(), nullable=False),
        sa.Column('value', JSON(), nullable=True),
        sa.Column('version', sa.Integer(), server_default='0', nullable=True),
        sa.ForeignKeyConstraint(['namespace_id'], [u'namespace.id'],
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'))
    op.create_index(op.f('ix_metadata_created_at'),
                    'metadata', ['created_at'],
                    unique=False)
    op.create_index(op.f('ix_metadata_deleted_at'),
                    'metadata', ['deleted_at'],
                    unique=False)
    op.create_index(op.f('ix_metadata_object_id'),
                    'metadata', ['object_id'],
                    unique=False)
    op.create_index(op.f('ix_metadata_object_public_id'),
                    'metadata', ['object_public_id'],
                    unique=False)
    op.create_index(op.f('ix_metadata_public_id'),
                    'metadata', ['public_id'],
                    unique=False)
    op.create_index(op.f('ix_metadata_updated_at'),
                    'metadata', ['updated_at'],
                    unique=False)
    op.create_index('ix_obj_public_id_app_id',
                    'metadata', ['object_public_id', 'app_id'],
                    unique=True)

    conn = op.get_bind()
    increment = (shard_id << 48) + 1
    conn.execute('ALTER TABLE metadata AUTO_INCREMENT={}'.format(increment))
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'Users', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('username', sa.String(length=20), nullable=True),
        sa.Column('password_hash', sa.BINARY(length=60), nullable=True),
        sa.Column('date_created', sa.DATETIME(), nullable=True),
        sa.Column('token', sa.String(), nullable=True),
        sa.PrimaryKeyConstraint('id'))
    op.create_index(op.f('ix_Users_username'),
                    'Users', ['username'],
                    unique=True)
    op.create_table('Bucketlists', sa.Column('id',
                                             sa.Integer(),
                                             nullable=False),
                    sa.Column('name', sa.String(length=125), nullable=False),
                    sa.Column('date_created', sa.DATETIME(), nullable=True),
                    sa.Column('date_modified', sa.DATETIME(), nullable=True),
                    sa.Column('created_by', sa.Integer(), nullable=True),
                    sa.ForeignKeyConstraint(
                        ['created_by'],
                        ['Users.id'],
                    ), sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'BucketlistItems', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(), nullable=False),
        sa.Column('description', sa.String(), nullable=True),
        sa.Column('date_created', sa.DATETIME(), nullable=True),
        sa.Column('date_modified', sa.DATETIME(), nullable=True),
        sa.Column('bucketlist_id', sa.Integer(), nullable=True),
        sa.Column('done', sa.Boolean(), nullable=True),
        sa.ForeignKeyConstraint(
            ['bucketlist_id'],
            ['Bucketlists.id'],
        ), sa.PrimaryKeyConstraint('id'))
Ejemplo n.º 6
0
def upgrade():
    op.create_table(
        'event',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('uid', sa.String(length=64), nullable=False),
        sa.Column('provider_name', sa.String(length=64), nullable=False),
        sa.Column('public_id', sa.BINARY(length=16), nullable=False),
        sa.Column('raw_data', sa.Text(), nullable=False),
        sa.Column('account_id', sa.Integer(), nullable=False),
        sa.Column('subject', sa.String(length=255), nullable=True),
        sa.Column('body', sa.Text(), nullable=True),
        sa.Column('location', sa.String(length=255), nullable=True),
        sa.Column('busy', sa.Boolean(), nullable=False),
        sa.Column('locked', sa.Boolean(), nullable=False),
        sa.Column('reminders', sa.String(length=255), nullable=True),
        sa.Column('recurrence', sa.String(length=255), nullable=True),
        sa.Column('start', sa.DateTime(), nullable=False),
        sa.Column('end', sa.DateTime(), nullable=True),
        sa.Column('all_day', sa.Boolean(), nullable=False),
        sa.Column('time_zone', sa.Integer(), nullable=False),
        sa.Column('source', sa.Enum('remote', 'local'), nullable=False),
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('deleted_at', sa.DateTime(), nullable=True),
        sa.ForeignKeyConstraint(['account_id'], ['account.id'],
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'),
    )
    op.add_column('account', sa.Column('last_synced_events', sa.DateTime(),
                                       nullable=True))
Ejemplo n.º 7
0
def upgrade():
    op.create_table(
        "event",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("uid", sa.String(length=64), nullable=False),
        sa.Column("provider_name", sa.String(length=64), nullable=False),
        sa.Column("public_id", sa.BINARY(length=16), nullable=False),
        sa.Column("raw_data", sa.Text(), nullable=False),
        sa.Column("account_id", sa.Integer(), nullable=False),
        sa.Column("subject", sa.String(length=255), nullable=True),
        sa.Column("body", sa.Text(), nullable=True),
        sa.Column("location", sa.String(length=255), nullable=True),
        sa.Column("busy", sa.Boolean(), nullable=False),
        sa.Column("locked", sa.Boolean(), nullable=False),
        sa.Column("reminders", sa.String(length=255), nullable=True),
        sa.Column("recurrence", sa.String(length=255), nullable=True),
        sa.Column("start", sa.DateTime(), nullable=False),
        sa.Column("end", sa.DateTime(), nullable=True),
        sa.Column("all_day", sa.Boolean(), nullable=False),
        sa.Column("time_zone", sa.Integer(), nullable=False),
        sa.Column("source", sa.Enum("remote", "local"), nullable=False),
        sa.Column("created_at", sa.DateTime(), nullable=True),
        sa.Column("updated_at", sa.DateTime(), nullable=True),
        sa.Column("deleted_at", sa.DateTime(), nullable=True),
        sa.ForeignKeyConstraint(["account_id"], ["account.id"],
                                ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
    )
    op.add_column(
        "account", sa.Column("last_synced_events",
                             sa.DateTime(),
                             nullable=True))
Ejemplo n.º 8
0
def upgrade():
    op.create_table(
        "eventparticipant",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("public_id", sa.BINARY(length=16), nullable=False),
        sa.Column("event_id", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=255), nullable=True),
        sa.Column("_raw_address", sa.String(length=191), nullable=True),
        sa.Column("_canonicalized_address",
                  sa.String(length=191),
                  nullable=True),
        sa.Column(
            "status",
            sa.Enum("yes", "no", "maybe", "awaiting"),
            default="awaiting",
            nullable=False,
        ),
        sa.Column("notes", sa.Text(), nullable=True),
        sa.Column("created_at", sa.DateTime(), nullable=True),
        sa.Column("updated_at", sa.DateTime(), nullable=True),
        sa.Column("deleted_at", sa.DateTime(), nullable=True),
        sa.ForeignKeyConstraint(["event_id"], ["event.id"],
                                ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("_raw_address", "event_id", name="uid"),
    )
Ejemplo n.º 9
0
def upgrade():
    # remove old events that didn't match foreign key constraints on calendars
    event = table('event')
    op.execute(event.delete())

    op.create_table(
        'calendar', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('public_id', sa.BINARY(length=16), nullable=False),
        sa.Column('account_id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(length=128), nullable=True),
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('deleted_at', sa.DateTime(), nullable=True),
        sa.Column('notes', sa.Text(), nullable=True),
        sa.Column('uid',
                  sa.String(767, collation='ascii_general_ci'),
                  nullable=False),
        sa.Column('read_only', sa.Boolean(), nullable=False, default=False),
        sa.ForeignKeyConstraint(['account_id'], ['account.id'],
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('account_id', 'name', name='uuid'))

    op.add_column(
        'account', sa.Column('default_calendar_id',
                             sa.Integer(),
                             nullable=True))

    op.create_foreign_key('default_calendar_ibfk_1', 'account', 'calendar',
                          ['default_calendar_id'], ['id'])
    op.add_column('event',
                  sa.Column('calendar_id', sa.Integer(), nullable=False))

    op.create_foreign_key('event_ibfk_2', 'event', 'calendar', ['calendar_id'],
                          ['id'])

    op.add_column('event',
                  sa.Column('owner', sa.String(length=255), nullable=True))

    op.add_column(
        'event',
        sa.Column('is_owner', sa.Boolean(), default=True, nullable=False))

    op.add_column('eventparticipant',
                  sa.Column('guests', sa.Integer(), default=0, nullable=False))

    op.alter_column('eventparticipant',
                    'status',
                    existing_type=sa.Enum('yes', 'no', 'maybe', 'awaiting'),
                    type_=sa.Enum('yes', 'no', 'maybe', 'noreply'),
                    existing_nullable=False)

    op.drop_column('event', 'locked')
    op.drop_column('event', 'time_zone')
    op.add_column('event', sa.Column('start_date', sa.Date(), nullable=True))
    op.add_column('event', sa.Column('end_date', sa.Date(), nullable=True))
    op.add_column(
        'event',
        sa.Column('read_only', sa.Boolean(), nullable=False, default=False))
Ejemplo n.º 10
0
def upgrade():
    # remove old events that didn't match foreign key constraints on calendars
    event = table("event")
    op.execute(event.delete())

    op.create_table(
        "calendar",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("public_id", sa.BINARY(length=16), nullable=False),
        sa.Column("account_id", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=128), nullable=True),
        sa.Column("created_at", sa.DateTime(), nullable=True),
        sa.Column("updated_at", sa.DateTime(), nullable=True),
        sa.Column("deleted_at", sa.DateTime(), nullable=True),
        sa.Column("notes", sa.Text(), nullable=True),
        sa.Column("uid", sa.String(767, collation="ascii_general_ci"), nullable=False),
        sa.Column("read_only", sa.Boolean(), nullable=False, default=False),
        sa.ForeignKeyConstraint(["account_id"], ["account.id"], ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("account_id", "name", name="uuid"),
    )

    op.add_column(
        "account", sa.Column("default_calendar_id", sa.Integer(), nullable=True)
    )

    op.create_foreign_key(
        "account_ibfk_10", "account", "calendar", ["default_calendar_id"], ["id"]
    )
    op.add_column("event", sa.Column("calendar_id", sa.Integer(), nullable=False))

    op.create_foreign_key("event_ibfk_2", "event", "calendar", ["calendar_id"], ["id"])

    op.add_column("event", sa.Column("owner", sa.String(length=255), nullable=True))

    op.add_column(
        "event", sa.Column("is_owner", sa.Boolean(), default=True, nullable=False)
    )

    op.add_column(
        "eventparticipant", sa.Column("guests", sa.Integer(), default=0, nullable=False)
    )

    op.alter_column(
        "eventparticipant",
        "status",
        existing_type=sa.Enum("yes", "no", "maybe", "awaiting"),
        type_=sa.Enum("yes", "no", "maybe", "noreply"),
        existing_nullable=False,
    )

    op.drop_column("event", "locked")
    op.drop_column("event", "time_zone")
    op.add_column("event", sa.Column("start_date", sa.Date(), nullable=True))
    op.add_column("event", sa.Column("end_date", sa.Date(), nullable=True))
    op.add_column(
        "event", sa.Column("read_only", sa.Boolean(), nullable=False, default=False)
    )
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('all_vouchers_log_sequence',
                    sa.Column('id', mysql.BIGINT(), nullable=False),
                    sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'all_vouchers_log', sa.Column('auto_id',
                                      mysql.BIGINT(),
                                      nullable=False),
        sa.Column('change_id', mysql.BIGINT(), nullable=False),
        sa.Column('changed_on', mysql.DATETIME(fsp=6), nullable=False),
        sa.Column('id', sa.BINARY(length=16), nullable=True),
        sa.Column('code', sa.VARCHAR(length=200), nullable=False),
        sa.Column('rules', sa.VARCHAR(length=150), nullable=False),
        sa.Column('custom', sa.VARCHAR(length=1000), nullable=True),
        sa.Column('description', sa.VARCHAR(length=255), nullable=True),
        sa.Column('from', mysql.DATETIME(fsp=6), nullable=True),
        sa.Column('to', mysql.DATETIME(fsp=6), nullable=True),
        sa.Column('schedule', sa.VARCHAR(length=250), nullable=True),
        sa.Column('mutable',
                  mysql.TINYINT(display_width=3, unsigned=True),
                  nullable=True),
        sa.Column('is_active',
                  mysql.TINYINT(display_width=3, unsigned=True),
                  nullable=False),
        sa.Column('type', mysql.TINYINT(unsigned=True), nullable=False),
        sa.Column('created_by', sa.VARCHAR(length=32), nullable=False),
        sa.Column('updated_by', sa.VARCHAR(length=32), nullable=False),
        sa.Column('created_at', mysql.DATETIME(fsp=6), nullable=False),
        sa.Column('updated_at', mysql.DATETIME(fsp=6), nullable=False),
        sa.Column('agent_id', mysql.INTEGER(), nullable=True),
        sa.PrimaryKeyConstraint('auto_id'))
    op.create_index(op.f('ix_all_vouchers_log_change_id'),
                    'all_vouchers_log', ['change_id'],
                    unique=False)
    op.create_index(op.f('ix_all_vouchers_log_changed_on'),
                    'all_vouchers_log', ['changed_on'],
                    unique=False)
    op.create_index(op.f('ix_all_vouchers_log_code'),
                    'all_vouchers_log', ['code'],
                    unique=False)
    op.create_index(op.f('ix_all_vouchers_log_id'),
                    'all_vouchers_log', ['id'],
                    unique=False)
    op.add_column(u'all_vouchers',
                  sa.Column('is_active', sa.BOOLEAN(), nullable=False))
    op.create_index(op.f('ix_all_vouchers_from'),
                    'all_vouchers', ['from'],
                    unique=False)
    op.create_index(op.f('ix_all_vouchers_to'),
                    'all_vouchers', ['to'],
                    unique=False)
    op.create_index('user_voucher_transaction_log_order_id',
                    'user_voucher_transaction_log', ['order_id'],
                    unique=False)
Ejemplo n.º 12
0
def downgrade():
    op.add_column(
        "spoolmessage",
        sa.Column(u"replyto_thread_id",
                  mysql.INTEGER(display_width=11),
                  nullable=True),
    )
    op.add_column(
        "spoolmessage",
        sa.Column(u"draft_copied_from",
                  mysql.INTEGER(display_width=11),
                  nullable=True),
    )
    op.drop_column("spoolmessage", "is_reply")
    op.create_table(
        u"draftthread",
        sa.Column(u"created_at", mysql.DATETIME(), nullable=False),
        sa.Column(u"updated_at", mysql.DATETIME(), nullable=False),
        sa.Column(u"deleted_at", mysql.DATETIME(), nullable=True),
        sa.Column(u"public_id", sa.BINARY(length=16), nullable=False),
        sa.Column(u"id", mysql.INTEGER(display_width=11), nullable=False),
        sa.Column(u"master_public_id", sa.BINARY(length=16), nullable=False),
        sa.Column(
            u"thread_id",
            mysql.INTEGER(display_width=11),
            autoincrement=False,
            nullable=False,
        ),
        sa.Column(
            u"message_id",
            mysql.INTEGER(display_width=11),
            autoincrement=False,
            nullable=False,
        ),
        sa.ForeignKeyConstraint(["message_id"], [u"message.id"],
                                name=u"draftthread_ibfk_2"),
        sa.ForeignKeyConstraint(["thread_id"], [u"thread.id"],
                                name=u"draftthread_ibfk_1"),
        sa.PrimaryKeyConstraint(u"id"),
        mysql_default_charset=u"utf8mb4",
        mysql_engine=u"InnoDB",
    )
Ejemplo n.º 13
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'clip',
        sa.Column('physical_id',
                  sa.Integer(),
                  autoincrement=True,
                  nullable=False),
        sa.Column('id', sa.BINARY(16), nullable=False),
        sa.Column('text', sa.TEXT(), nullable=False),
        sa.Column('channel_name', sa.String(length=255), nullable=True),
        sa.PrimaryKeyConstraint('physical_id'), sa.UniqueConstraint('id'))
Ejemplo n.º 14
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'users', sa.Column('id', sa.BINARY(length=16), nullable=False),
        sa.Column('username', sa.String(length=32), nullable=False),
        sa.Column('email', sa.String(length=255), nullable=False),
        sa.Column('password', sa.String(length=128), nullable=False),
        sa.Column('rank', sa.Integer(), nullable=False),
        sa.Column('created_at', sa.DateTime(), nullable=False),
        sa.Column('updated_at', sa.DateTime(), nullable=False),
        sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email'),
        sa.UniqueConstraint('username'))
Ejemplo n.º 15
0
def downgrade():
    op.add_column(
        'spoolmessage',
        sa.Column(u'replyto_thread_id',
                  mysql.INTEGER(display_width=11),
                  nullable=True))
    op.add_column(
        'spoolmessage',
        sa.Column(u'draft_copied_from',
                  mysql.INTEGER(display_width=11),
                  nullable=True))
    op.drop_column('spoolmessage', 'is_reply')
    op.create_table(u'draftthread',
                    sa.Column(u'created_at', mysql.DATETIME(), nullable=False),
                    sa.Column(u'updated_at', mysql.DATETIME(), nullable=False),
                    sa.Column(u'deleted_at', mysql.DATETIME(), nullable=True),
                    sa.Column(u'public_id',
                              sa.BINARY(length=16),
                              nullable=False),
                    sa.Column(u'id',
                              mysql.INTEGER(display_width=11),
                              nullable=False),
                    sa.Column(u'master_public_id',
                              sa.BINARY(length=16),
                              nullable=False),
                    sa.Column(u'thread_id',
                              mysql.INTEGER(display_width=11),
                              autoincrement=False,
                              nullable=False),
                    sa.Column(u'message_id',
                              mysql.INTEGER(display_width=11),
                              autoincrement=False,
                              nullable=False),
                    sa.ForeignKeyConstraint(['message_id'], [u'message.id'],
                                            name=u'draftthread_ibfk_2'),
                    sa.ForeignKeyConstraint(['thread_id'], [u'thread.id'],
                                            name=u'draftthread_ibfk_1'),
                    sa.PrimaryKeyConstraint(u'id'),
                    mysql_default_charset=u'utf8mb4',
                    mysql_engine=u'InnoDB')
Ejemplo n.º 16
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('users',
                    sa.Column('id', sa.String(length=32), nullable=False),
                    sa.Column('name', sa.String(length=70), nullable=False),
                    sa.Column('email', sa.String(length=320), nullable=False),
                    sa.Column('password_hash',
                              sa.BINARY(length=60),
                              nullable=False),
                    sa.PrimaryKeyConstraint('id'),
                    sa.UniqueConstraint('email'),
                    mysql_charset='utf8mb4',
                    mysql_engine='InnoDB')
def upgrade():
    shard_id = int(context.config.get_main_option('shard_id'))
    namespace_id_type = sa.Integer() if shard_id == 0 else sa.BigInteger()

    op.create_table(
        'accounttransaction',
        sa.Column('created_at', sa.DateTime(), nullable=False),
        sa.Column('updated_at', sa.DateTime(), nullable=False),
        sa.Column('deleted_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.BigInteger(), nullable=False),
        sa.Column('public_id', sa.BINARY(length=16), nullable=False),
        sa.Column('namespace_id', namespace_id_type, nullable=True),
        sa.Column('object_type', sa.String(20), nullable=False),
        sa.Column('record_id', sa.BigInteger(), nullable=False),
        sa.Column('object_public_id', sa.String(191), nullable=False),
        sa.Column('command',
                  sa.Enum('insert', 'update', 'delete'),
                  nullable=False), sa.PrimaryKeyConstraint('id'),
        sa.ForeignKeyConstraint(
            ['namespace_id'],
            [u'namespace.id'],
        ))
    op.create_index('ix_accounttransaction_created_at',
                    'accounttransaction', ['created_at'],
                    unique=False)
    op.create_index('ix_accounttransaction_updated_at',
                    'accounttransaction', ['updated_at'],
                    unique=False)
    op.create_index('ix_accounttransaction_deleted_at',
                    'accounttransaction', ['deleted_at'],
                    unique=False)
    op.create_index('ix_accounttransaction_table_name',
                    'accounttransaction', ['object_type'],
                    unique=False)
    op.create_index('ix_accounttransaction_command',
                    'accounttransaction', ['command'],
                    unique=False)
    op.create_index('ix_accounttransaction_object_type_record_id',
                    'accounttransaction', ['object_type', 'record_id'],
                    unique=False)
    op.create_index('ix_accounttransaction_namespace_id_created_at',
                    'accounttransaction', ['namespace_id', 'created_at'],
                    unique=False)

    conn = op.get_bind()
    increment = (shard_id << 48) + 1
    conn.execute(
        'ALTER TABLE accounttransaction AUTO_INCREMENT={}'.format(increment))
Ejemplo n.º 18
0
def upgrade():
    op.create_table(
        'monitor_dispatcher',
        sa.Column('checkFn',
                  sa.String(length=80),
                  nullable=False,
                  primary_key=True),
        sa.Column('excType',
                  sa.String(length=80),
                  nullable=False,
                  primary_key=True),
        sa.Column('excValueDigest',
                  sa.BINARY(length=20),
                  nullable=True,
                  primary_key=True),
        sa.Column('timestamp', sa.DATETIME(), nullable=False),
        sa.Column('excValue', sa.Text(), nullable=True))
    op.create_index('timestamp_index',
                    'monitor_dispatcher', ['timestamp'],
                    unique=False)
Ejemplo n.º 19
0
def upgrade():
    op.create_table(
        'measure_block',
        sa.Column('id',
                  BigInteger(unsigned=True),
                  primary_key=True,
                  autoincrement=True),
        sa.Column('measure_type', sa.SmallInteger()),
        sa.Column('s3_key', sa.String(80)),
        sa.Column('archive_date', sa.DateTime()),
        sa.Column('archive_sha', sa.BINARY(length=20)),
        sa.Column('start_id', BigInteger(unsigned=True)),
        sa.Column('end_id', BigInteger(unsigned=True)),
        mysql_engine='InnoDB',
        mysql_charset='utf8',
        mysql_row_format='compressed',
        mysql_key_block_size='4',
    )
    op.create_index('idx_measure_block_archive_date', 'measure_block',
                    ['archive_date'])
    op.create_index('idx_measure_block_s3_key', 'measure_block', ['s3_key'])
    op.create_index('idx_measure_block_end_id', 'measure_block', ['end_id'])
Ejemplo n.º 20
0
def upgrade():
    op.create_table(
        'eventparticipant', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('public_id', sa.BINARY(length=16), nullable=False),
        sa.Column('event_id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(length=255), nullable=True),
        sa.Column('_raw_address', sa.String(length=191), nullable=True),
        sa.Column('_canonicalized_address',
                  sa.String(length=191),
                  nullable=True),
        sa.Column('status',
                  sa.Enum('yes', 'no', 'maybe', 'awaiting'),
                  default='awaiting',
                  nullable=False), sa.Column('notes', sa.Text(),
                                             nullable=True),
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('deleted_at', sa.DateTime(), nullable=True),
        sa.ForeignKeyConstraint(['event_id'], ['event.id'],
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('_raw_address', 'event_id', name='uid'))
def downgrade():
    op.alter_column("producer_mapping",
                    "info",
                    nullable=True,
                    existing_type=sa.JSON)
    op.alter_column("producer_mapping",
                    "scraper_id",
                    nullable=True,
                    existing_type=sa.Integer)
    op.alter_column("producer_mapping",
                    "producer_id",
                    nullable=True,
                    existing_type=sa.BINARY(16))
    op.alter_column("producer",
                    "url",
                    nullable=True,
                    existing_type=sa.String(1024))
    op.alter_column("producer",
                    "name",
                    nullable=True,
                    type_=sa.Text,
                    existing_type=sa.String(255))
Ejemplo n.º 22
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'clay',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('name', sa.String(length=64), nullable=True),
        sa.PrimaryKeyConstraint('id'))
    op.create_index(op.f('ix_clay_name'), 'clay', ['name'], unique=True)
    op.create_table(
        'item',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('name', sa.String(length=64), nullable=True),
        sa.Column('clay_id_1', sa.Integer(), nullable=True),
        sa.Column('clay_id_2', sa.Integer(), nullable=True),
        sa.Column('picture', sa.BINARY(), nullable=True),
        sa.ForeignKeyConstraint(
            ['clay_id_1'],
            ['clay.id'],
        ), sa.ForeignKeyConstraint(
            ['clay_id_2'],
            ['clay.id'],
        ), sa.PrimaryKeyConstraint('id'))
    op.create_index(op.f('ix_item_name'), 'item', ['name'], unique=True)
def upgrade():
    op.alter_column("producer",
                    "name",
                    nullable=False,
                    type_=sa.String(255),
                    existing_type=sa.Text)
    op.alter_column("producer",
                    "url",
                    nullable=False,
                    existing_type=sa.String(1024))
    op.alter_column("producer_mapping",
                    "producer_id",
                    nullable=False,
                    existing_type=sa.BINARY(16))
    op.execute("UPDATE producer_mapping SET scraper_id = 1")
    op.alter_column("producer_mapping",
                    "scraper_id",
                    nullable=False,
                    existing_type=sa.Integer)
    op.alter_column("producer_mapping",
                    "info",
                    nullable=False,
                    existing_type=sa.JSON)
Ejemplo n.º 24
0
def upgrade():
    op.create_table(
        "category",
        sa.Column("created_at", sa.DateTime(), nullable=False),
        sa.Column("updated_at", sa.DateTime(), nullable=False),
        sa.Column("deleted_at", sa.DateTime(), nullable=True),
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("public_id", sa.BINARY(16), nullable=False),
        sa.Column("namespace_id", sa.Integer(), nullable=False),
        sa.Column("name",
                  sa.String(length=191, collation="utf8mb4_bin"),
                  nullable=True),
        sa.Column("display_name", sa.String(length=191), nullable=False),
        sa.Column("type_", sa.Enum("folder", "label"), nullable=False),
        sa.ForeignKeyConstraint(["namespace_id"], ["namespace.id"],
                                name="category_fk1",
                                ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("namespace_id", "name", "display_name"),
        sa.UniqueConstraint("namespace_id", "public_id"),
    )
    op.create_index("ix_category_public_id",
                    "category", ["public_id"],
                    unique=False)
    op.create_index("ix_category_created_at",
                    "category", ["created_at"],
                    unique=False)
    op.create_index("ix_category_deleted_at",
                    "category", ["deleted_at"],
                    unique=False)
    op.create_index("ix_category_updated_at",
                    "category", ["updated_at"],
                    unique=False)
    op.create_table(
        "label",
        sa.Column("created_at", sa.DateTime(), nullable=False),
        sa.Column("updated_at", sa.DateTime(), nullable=False),
        sa.Column("deleted_at", sa.DateTime(), nullable=True),
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("account_id", sa.Integer(), nullable=False),
        sa.Column("name",
                  sa.String(length=191, collation="utf8mb4_bin"),
                  nullable=False),
        sa.Column("canonical_name", sa.String(length=191), nullable=True),
        sa.Column("category_id", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(["account_id"], ["account.id"],
                                name="label_fk1",
                                ondelete="CASCADE"),
        sa.ForeignKeyConstraint(
            ["category_id"],
            [u"category.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
        sa.UniqueConstraint("account_id", "name"),
    )
    op.create_index("ix_label_created_at",
                    "label", ["created_at"],
                    unique=False)
    op.create_index("ix_label_deleted_at",
                    "label", ["deleted_at"],
                    unique=False)
    op.create_index("ix_label_updated_at",
                    "label", ["updated_at"],
                    unique=False)
    op.create_table(
        "messagecategory",
        sa.Column("created_at", sa.DateTime(), nullable=False),
        sa.Column("updated_at", sa.DateTime(), nullable=False),
        sa.Column("deleted_at", sa.DateTime(), nullable=True),
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("message_id", sa.Integer(), nullable=False),
        sa.Column("category_id", sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(["category_id"], [u"category.id"],
                                ondelete="CASCADE"),
        sa.ForeignKeyConstraint(["message_id"], [u"message.id"],
                                ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index("ix_messagecategory_created_at",
                    "messagecategory", ["created_at"],
                    unique=False)
    op.create_index("ix_messagecategory_deleted_at",
                    "messagecategory", ["deleted_at"],
                    unique=False)
    op.create_index("ix_messagecategory_updated_at",
                    "messagecategory", ["updated_at"],
                    unique=False)
    op.create_index(
        "message_category_ids",
        "messagecategory",
        ["message_id", "category_id"],
        unique=False,
    )
    op.create_table(
        "labelitem",
        sa.Column("created_at", sa.DateTime(), nullable=False),
        sa.Column("updated_at", sa.DateTime(), nullable=False),
        sa.Column("deleted_at", sa.DateTime(), nullable=True),
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("imapuid_id", sa.Integer(), nullable=False),
        sa.Column("label_id", sa.Integer(), nullable=False),
        sa.ForeignKeyConstraint(["imapuid_id"], [u"imapuid.id"],
                                ondelete="CASCADE"),
        sa.ForeignKeyConstraint(["label_id"], [u"label.id"],
                                ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index("imapuid_label_ids",
                    "labelitem", ["imapuid_id", "label_id"],
                    unique=False)
    op.create_index("ix_labelitem_created_at",
                    "labelitem", ["created_at"],
                    unique=False)
    op.create_index("ix_labelitem_deleted_at",
                    "labelitem", ["deleted_at"],
                    unique=False)
    op.create_index("ix_labelitem_updated_at",
                    "labelitem", ["updated_at"],
                    unique=False)
    op.add_column("folder",
                  sa.Column("category_id", sa.Integer(), nullable=True))
    op.create_foreign_key("folder_ibfk_2", "folder", "category",
                          ["category_id"], ["id"])

    from inbox.ignition import main_engine

    engine = main_engine(pool_size=1, max_overflow=0)
    if engine.has_table("easfoldersyncstatus"):
        op.add_column("easfoldersyncstatus",
                      sa.Column("category_id", sa.Integer(), nullable=True))
        op.create_foreign_key(
            "easfoldersyncstatus_ibfk_3",
            "easfoldersyncstatus",
            "category",
            ["category_id"],
            ["id"],
        )

    op.add_column(
        "message",
        sa.Column(
            "is_starred",
            sa.Boolean(),
            server_default=sa.sql.expression.false(),
            nullable=False,
        ),
    )
def upgrade():
    shard_id = int(context.config.get_main_option("shard_id"))
    namespace_id_type = sa.Integer() if shard_id == 0 else sa.BigInteger()

    op.create_table(
        "accounttransaction",
        sa.Column("created_at", sa.DateTime(), nullable=False),
        sa.Column("updated_at", sa.DateTime(), nullable=False),
        sa.Column("deleted_at", sa.DateTime(), nullable=True),
        sa.Column("id", sa.BigInteger(), nullable=False),
        sa.Column("public_id", sa.BINARY(length=16), nullable=False),
        sa.Column("namespace_id", namespace_id_type, nullable=True),
        sa.Column("object_type", sa.String(20), nullable=False),
        sa.Column("record_id", sa.BigInteger(), nullable=False),
        sa.Column("object_public_id", sa.String(191), nullable=False),
        sa.Column("command",
                  sa.Enum("insert", "update", "delete"),
                  nullable=False),
        sa.PrimaryKeyConstraint("id"),
        sa.ForeignKeyConstraint(
            ["namespace_id"],
            [u"namespace.id"],
        ),
    )
    op.create_index(
        "ix_accounttransaction_created_at",
        "accounttransaction",
        ["created_at"],
        unique=False,
    )
    op.create_index(
        "ix_accounttransaction_updated_at",
        "accounttransaction",
        ["updated_at"],
        unique=False,
    )
    op.create_index(
        "ix_accounttransaction_deleted_at",
        "accounttransaction",
        ["deleted_at"],
        unique=False,
    )
    op.create_index(
        "ix_accounttransaction_table_name",
        "accounttransaction",
        ["object_type"],
        unique=False,
    )
    op.create_index("ix_accounttransaction_command",
                    "accounttransaction", ["command"],
                    unique=False)
    op.create_index(
        "ix_accounttransaction_object_type_record_id",
        "accounttransaction",
        ["object_type", "record_id"],
        unique=False,
    )
    op.create_index(
        "ix_accounttransaction_namespace_id_created_at",
        "accounttransaction",
        ["namespace_id", "created_at"],
        unique=False,
    )

    conn = op.get_bind()
    increment = (shard_id << 48) + 1
    conn.execute(
        "ALTER TABLE accounttransaction AUTO_INCREMENT={}".format(increment))
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('notification',
                  sa.Column('name', sa.BINARY(length=16), nullable=True))
    op.drop_column('notification', 'title')
Ejemplo n.º 27
0
def upgrade():
    # Enum tables (will be prepopulated with values through bulk_insert)

    alarm_states = op.create_table('alarm_state',
                                   sa.Column('name',
                                             sa.String(length=20),
                                             nullable=False),
                                   sa.PrimaryKeyConstraint('name'),
                                   mysql_charset='utf8mb4',
                                   mysql_collate='utf8mb4_unicode_ci'
                                   )

    op.bulk_insert(alarm_states,
                   [{'name': 'UNDETERMINED'},
                    {'name': 'OK'},
                    {'name': 'ALARM'}])

    ad_severities = op.create_table(
        'alarm_definition_severity',
        sa.Column('name',
                  sa.String(length=20),
                  nullable=False),
        sa.PrimaryKeyConstraint('name'),
        mysql_charset='utf8mb4',
        mysql_collate='utf8mb4_unicode_ci')

    op.bulk_insert(ad_severities,
                   [{'name': 'LOW'},
                    {'name': 'MEDIUM'},
                    {'name': 'HIGH'},
                    {'name': 'CRITICAL'}])

    nm_types = op.create_table(
        'notification_method_type',
        sa.Column('name',
                  sa.String(length=20),
                  nullable=False),
        sa.PrimaryKeyConstraint('name'),
        mysql_charset='utf8mb4',
        mysql_collate='utf8mb4_unicode_ci')

    op.bulk_insert(nm_types,
                   [{'name': 'EMAIL'},
                    {'name': 'WEBHOOK'},
                    {'name': 'PAGERDUTY'}])

    stream_action_types = op.create_table(
        'stream_actions_action_type',
        sa.Column('name',
                  sa.String(length=20),
                  nullable=False),
        sa.PrimaryKeyConstraint('name'),
        mysql_charset='utf8mb4',
        mysql_collate='utf8mb4_unicode_ci')

    op.bulk_insert(stream_action_types,
                   [{'name': 'FIRE'},
                    {'name': 'EXPIRE'}])

    op.create_table(
        'alarm_definition',
        sa.Column('id',
                  sa.String(length=36),
                  nullable=False),
        sa.Column('tenant_id',
                  sa.String(length=36),
                  nullable=False),
        sa.Column('name',
                  sa.String(length=255),
                  nullable=False,
                  server_default=''),
        sa.Column('description',
                  sa.String(length=255),
                  nullable=True,
                  server_default=None),
        sa.Column('expression',
                  sa.dialects.mysql.LONGTEXT(),
                  nullable=False),
        sa.Column('severity',
                  sa.String(length=20),
                  nullable=False),
        sa.Column('match_by',
                  sa.String(length=255),
                  nullable=True,
                  server_default=''),
        sa.Column('actions_enabled',
                  sa.Boolean(),
                  nullable=False,
                  server_default='1'),
        sa.Column('created_at',
                  sa.DateTime(),
                  nullable=False),
        sa.Column('updated_at',
                  sa.DateTime(),
                  nullable=False),
        sa.Column('deleted_at',
                  sa.DateTime(),
                  nullable=True,
                  server_default=None),
        sa.PrimaryKeyConstraint('id'),
        sa.Index('tenant_id', 'tenant_id'),
        sa.Index('deleted_at', 'deleted_at'),
        sa.Index('fk_alarm_definition_severity', 'severity'),
        sa.ForeignKeyConstraint(['severity'],
                                ['alarm_definition_severity.name']),
        mysql_charset='utf8mb4',
        mysql_collate='utf8mb4_unicode_ci')

    op.create_table(
        'alarm',
        sa.Column('id',
                  sa.String(length=36),
                  nullable=False),
        sa.Column('alarm_definition_id',
                  sa.String(length=36),
                  nullable=False,
                  server_default=''),
        sa.Column('state',
                  sa.String(length=20),
                  nullable=False),
        sa.Column('lifecycle_state',
                  sa.String(length=50, collation=False),
                  nullable=True,
                  server_default=None),
        sa.Column('link',
                  sa.String(length=512, collation=False),
                  nullable=True,
                  server_default=None),
        sa.Column('created_at',
                  sa.DateTime(),
                  nullable=False),
        sa.Column('state_updated_at',
                  sa.DateTime(),
                  nullable=True),
        sa.Column('updated_at',
                  sa.DateTime(),
                  nullable=False),
        sa.PrimaryKeyConstraint('id'),
        sa.Index('alarm_definition_id', 'alarm_definition_id'),
        sa.Index('fk_alarm_alarm_state', 'state'),
        sa.ForeignKeyConstraint(['alarm_definition_id'],
                                ['alarm_definition.id'],
                                name='fk_alarm_definition_id',
                                ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['state'],
                                ['alarm_state.name'],
                                name='fk_alarm_alarm_state'),
        mysql_charset='utf8mb4',
        mysql_collate='utf8mb4_unicode_ci')

    op.create_table(
        'notification_method',
        sa.Column('id',
                  sa.String(length=36),
                  nullable=False),
        sa.Column('tenant_id',
                  sa.String(length=36),
                  nullable=False),
        sa.Column('name',
                  sa.String(length=250),
                  nullable=True,
                  server_default=None),
        sa.Column('type',
                  sa.String(length=20),
                  # Note: the typo below is deliberate since we need to match
                  # the constraint name from the SQL script where it is
                  # misspelled as well.
                  sa.ForeignKey('notification_method_type.name',
                                name='fk_alarm_noticication_method_type'),
                  nullable=False),
        sa.Column('address',
                  sa.String(length=512),
                  nullable=True,
                  server_default=None),
        sa.Column('created_at',
                  sa.DateTime(),
                  nullable=False),
        sa.Column('updated_at',
                  sa.DateTime(),
                  nullable=False),
        sa.PrimaryKeyConstraint('id'),
        mysql_charset='utf8mb4',
        mysql_collate='utf8mb4_unicode_ci')

    op.create_table(
        'alarm_action',
        sa.Column('alarm_definition_id',
                  sa.String(length=36),
                  nullable=False,),
        sa.Column('alarm_state',
                  sa.String(length=20),
                  nullable=False),
        sa.Column('action_id',
                  sa.String(length=36),
                  nullable=False),
        sa.PrimaryKeyConstraint('alarm_definition_id', 'alarm_state',
                                'action_id'),
        sa.ForeignKeyConstraint(['action_id'],
                                ['notification_method.id'],
                                name='fk_alarm_action_notification_method_id',
                                ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['alarm_state'],
                                ['alarm_state.name']),
        sa.ForeignKeyConstraint(['alarm_definition_id'],
                                ['alarm_definition.id'],
                                ondelete='CASCADE'),
        mysql_charset='utf8mb4',
        mysql_collate='utf8mb4_unicode_ci')

    op.create_table(
        'alarm_metric',
        sa.Column('alarm_id',
                  sa.String(length=36),
                  nullable=False),
        sa.Column('metric_definition_dimensions_id',
                  sa.BINARY(20),
                  nullable=False,
                  server_default='\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'),
        sa.PrimaryKeyConstraint('alarm_id', 'metric_definition_dimensions_id'),
        sa.Index('alarm_id', 'alarm_id'),
        sa.Index('metric_definition_dimensions_id', 'metric_definition_dimensions_id'),
        mysql_charset='utf8mb4',
        mysql_collate='utf8mb4_unicode_ci')

    # For some mysterious alembic/sqlalchemy reason this foreign key constraint
    # ends up missing when specified upon table creation. Hence we need to add
    # it through an ALTER TABLE operation:
    op.create_foreign_key('fk_alarm_id',
                          'alarm_metric',
                          'alarm',
                          ['alarm_id'],
                          ['id'], ondelete='CASCADE')

    op.create_table(
        'metric_definition',
        sa.Column('id',
                  sa.BINARY(20),
                  nullable=False,
                  server_default='\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'),
        sa.Column('name',
                  sa.String(length=255),
                  nullable=False),
        sa.Column('tenant_id',
                  sa.String(length=36),
                  nullable=False),
        sa.Column('region',
                  sa.String(length=255),
                  nullable=False,
                  server_default=''),
        sa.PrimaryKeyConstraint('id'),
        mysql_charset='utf8mb4',
        mysql_collate='utf8mb4_unicode_ci')

    op.create_table(
        'metric_definition_dimensions',
        sa.Column('id',
                  sa.BINARY(20),
                  nullable=False,
                  server_default='\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'),
        sa.Column('metric_definition_id',
                  sa.BINARY(20),
                  nullable=False,
                  server_default='\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'),
        sa.Column('metric_dimension_set_id',
                  sa.BINARY(20),
                  nullable=False,
                  server_default='\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'),
        sa.PrimaryKeyConstraint('id'),
        sa.Index('metric_definition_id', 'metric_definition_id'),
        sa.Index('metric_dimension_set_id', 'metric_dimension_set_id'),
        mysql_charset='utf8mb4',
        mysql_collate='utf8mb4_unicode_ci')

    # mysql limits the size of a unique key to 767 bytes. The utf8mb4 charset
    # requires 4 bytes to be allocated for each character while the utf8
    # charset requires 3 bytes.  The utf8 charset should be sufficient for any
    # reasonable characters, see the definition of supplementary characters for
    # what it doesn't support.  Even with utf8, the unique key length would be
    # 785 bytes so only a subset of the name is used. Potentially the size of
    # the name should be limited to 250 characters which would resolve this
    # issue.
    #
    # The unique key is required to allow high performance inserts without
    # doing a select by using the "insert into metric_dimension ... on
    # duplicate key update dimension_set_id=dimension_set_id syntax

    op.create_table(
        'metric_dimension',
        sa.Column('dimension_set_id',
                  sa.BINARY(20),
                  nullable=False,
                  server_default='\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0'),
        sa.Column('name',
                  sa.String(length=255),
                  nullable=False,
                  server_default=''),
        sa.Column('value',
                  sa.String(length=255),
                  nullable=False,
                  server_default=''),
        sa.Index('metric_dimension_key',
                 'dimension_set_id', 'name',
                 unique=True,
                 mysql_length={'name': 252}),
        sa.Index('dimension_set_id', 'dimension_set_id'),
        mysql_charset='utf8',
        mysql_collate='utf8_unicode_ci',
        mysql_comment='PRIMARY KEY (`id`)')

    op.create_table(
        'sub_alarm_definition',
        sa.Column('id',
                  sa.String(length=36),
                  nullable=False),
        sa.Column('alarm_definition_id',
                  sa.String(length=36),
                  sa.ForeignKey('alarm_definition.id', ondelete='CASCADE',
                                name='fk_sub_alarm_definition'),
                  nullable=False,
                  server_default=''),
        sa.Column('function',
                  sa.String(length=10),
                  nullable=False),
        sa.Column('metric_name',
                  sa.String(length=100),
                  nullable=True,
                  server_default=None),
        sa.Column('operator',
                  sa.String(length=5),
                  nullable=False),
        sa.Column('threshold',
                  sa.dialects.mysql.DOUBLE(),
                  nullable=False),
        sa.Column('period',
                  sa.Integer(),
                  nullable=False),
        sa.Column('periods',
                  sa.Integer(),
                  nullable=False),
        sa.Column('created_at',
                  sa.DateTime(),
                  nullable=False),
        sa.Column('updated_at',
                  sa.DateTime(),
                  nullable=False),
        sa.PrimaryKeyConstraint('id'),
        mysql_charset='utf8mb4',
        mysql_collate='utf8mb4_unicode_ci')

    op.create_table(
        'sub_alarm_definition_dimension',
        sa.Column('sub_alarm_definition_id',
                  sa.String(length=36),
                  sa.ForeignKey('sub_alarm_definition.id', ondelete='CASCADE',
                                name='fk_sub_alarm_definition_dimension'),
                  nullable=False,
                  server_default=''),
        sa.Column('dimension_name',
                  sa.String(length=255),
                  nullable=False,
                  server_default=''),
        sa.Column('value',
                  sa.String(length=255),
                  nullable=True,
                  server_default=None),
        mysql_charset='utf8mb4',
        mysql_collate='utf8mb4_unicode_ci')

    op.create_table(
        'sub_alarm',
        sa.Column('id',
                  sa.String(length=36),
                  nullable=False),
        sa.Column('alarm_id',
                  sa.String(length=36),
                  sa.ForeignKey('alarm.id', ondelete='CASCADE',
                                name='fk_sub_alarm'),
                  nullable=False,
                  server_default=''),
        sa.Column('sub_expression_id',
                  sa.String(length=36),
                  sa.ForeignKey('sub_alarm_definition.id',
                                name='fk_sub_alarm_expr'),
                  nullable=False,
                  server_default=''),
        sa.Column('expression',
                  sa.dialects.mysql.LONGTEXT(),
                  nullable=False),
        sa.Column('created_at',
                  sa.DateTime(),
                  nullable=False),
        sa.Column('updated_at',
                  sa.DateTime(),
                  nullable=False),
        sa.PrimaryKeyConstraint('id'),
        mysql_charset='utf8mb4',
        mysql_collate='utf8mb4_unicode_ci')

    op.create_table(
        'schema_migrations',
        sa.Column('version',
                  sa.String(length=255),
                  nullable=False),
        sa.UniqueConstraint('version', name='unique_schema_migrations'),
        mysql_charset='latin1')

    op.create_table(
        'stream_definition',
        sa.Column('id',
                  sa.String(length=36),
                  nullable=False),
        sa.Column('tenant_id',
                  sa.String(length=36),
                  nullable=False),
        sa.Column('name',
                  sa.String(length=190),
                  nullable=False,
                  server_default=''),
        sa.Column('description',
                  sa.String(length=255),
                  nullable=True,
                  server_default=None),
        sa.Column('select_by',
                  sa.dialects.mysql.LONGTEXT(),
                  nullable=True,
                  server_default=None),
        sa.Column('group_by',
                  sa.dialects.mysql.LONGTEXT(length=20),
                  nullable=True,
                  server_default=None),
        sa.Column('fire_criteria',
                  sa.dialects.mysql.LONGTEXT(length=20),
                  nullable=True,
                  server_default=None),
        sa.Column('expiration',
                  sa.dialects.mysql.INTEGER(display_width=10,
                                            unsigned=True),
                  nullable=True,
                  server_default='0'),
        sa.Column('actions_enabled',
                  sa.Boolean(),
                  nullable=False,
                  server_default='1'),
        sa.Column('created_at',
                  sa.DateTime(),
                  nullable=False),
        sa.Column('updated_at',
                  sa.DateTime(),
                  nullable=False),
        sa.Column('deleted_at',
                  sa.DateTime(),
                  nullable=True,
                  server_default=None),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('tenant_id', 'name', name='tenant_name'),
        sa.Index('name', 'name'),
        sa.Index('tenant_id', 'tenant_id'),
        sa.Index('deleted_at', 'deleted_at'),
        sa.Index('created_at', 'created_at'),
        sa.Index('updated_at', 'updated_at'),
        mysql_charset='utf8mb4',
        mysql_collate='utf8mb4_unicode_ci')

    op.create_table(
        'stream_actions',
        sa.Column('stream_definition_id',
                  sa.String(length=36),
                  sa.ForeignKey
                  ('stream_definition.id',
                   name='fk_stream_action_stream_definition_id',
                   ondelete='CASCADE'),
                  nullable=False),
        sa.Column('action_id',
                  sa.String(length=36),
                  sa.ForeignKey('notification_method.id',
                                name='fk_stream_action_notification_method_id',
                                ondelete='CASCADE'),
                  nullable=False),
        sa.Column('action_type',
                  sa.String(length=20),
                  sa.ForeignKey('stream_actions_action_type.name'),
                  nullable=False),
        sa.PrimaryKeyConstraint('stream_definition_id', 'action_id',
                                'action_type'),
        sa.Index('stream_definition_id', 'stream_definition_id'),
        sa.Index('action_type', 'action_type'),
        mysql_charset='utf8mb4',
        mysql_collate='utf8mb4_unicode_ci')

    op.create_table(
        'event_transform',
        sa.Column('id',
                  sa.dialects.mysql.VARCHAR(length=36, charset='utf8mb4',
                                            collation='utf8mb4_unicode_ci'),
                  nullable=False),
        sa.Column('tenant_id',
                  sa.dialects.mysql.VARCHAR(length=36, charset='utf8mb4',
                                            collation='utf8mb4_unicode_ci'),
                  nullable=False),
        sa.Column('name',
                  sa.dialects.mysql.VARCHAR(length=64, charset='utf8mb4',
                                            collation='utf8mb4_unicode_ci'),
                  nullable=False),
        sa.Column('description',
                  sa.dialects.mysql.VARCHAR(length=250, charset='utf8mb4',
                                            collation='utf8mb4_unicode_ci'),
                  nullable=False),
        sa.Column('specification',
                  sa.dialects.mysql.LONGTEXT(charset='utf8mb4',
                                             collation='utf8mb4_unicode_ci'),
                  nullable=False),
        sa.Column('enabled',
                  sa.Boolean(),
                  nullable=True,
                  server_default=None),
        sa.Column('created_at',
                  sa.DateTime(),
                  nullable=False),
        sa.Column('updated_at',
                  sa.DateTime(),
                  nullable=False),
        sa.Column('deleted_at',
                  sa.DateTime(),
                  nullable=True,
                  server_default=None),
        sa.PrimaryKeyConstraint('id'),
        sa.Index('name', 'name'),
        sa.Index('tenant_id', 'tenant_id'),
        sa.Index('deleted_at', 'deleted_at'),
        sa.Index('created_at', 'created_at'),
        sa.Index('updated_at', 'updated_at'),
        sa.UniqueConstraint('tenant_id', 'name', name='tenant_name'),
        mysql_charset='utf8mb4')
Ejemplo n.º 28
0
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'source',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('name', sa.String(length=50), nullable=True),
        sa.Column('address1', sa.String(length=120), nullable=True),
        sa.Column('address2', sa.String(length=120), nullable=True),
        sa.Column('city', sa.String(length=50), nullable=True),
        sa.Column('state', sa.String(length=2), nullable=True),
        sa.Column('zip_code', sa.String(length=10), nullable=True),
        sa.Column('source', sa.String(length=10), nullable=True),
        sa.PrimaryKeyConstraint('id'))
    op.create_table(
        'user',
        sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
        sa.Column('firstname', sa.String(length=50), nullable=True),
        sa.Column('lastname', sa.String(length=50), nullable=True),
        sa.Column('email', sa.String(length=120), nullable=True),
        sa.Column('phone', sa.String(length=50), nullable=True),
        sa.Column('fax', sa.String(length=50), nullable=True),
        sa.Column('job_type', sa.String(length=50), nullable=True),
        sa.Column('role', sa.String(length=50), nullable=True),
        sa.Column('password', sa.String(length=60), nullable=True),
        sa.Column('source_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['source_id'],
            ['source.id'],
        ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('email'))
    op.create_table(
        'referral', sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('firstname', sa.String(length=50), nullable=True),
        sa.Column('lastname', sa.String(length=50), nullable=True),
        sa.Column('phone', sa.String(length=50), nullable=True),
        sa.Column('email', sa.String(length=255), nullable=True),
        sa.Column('dob', sa.DateTime(), nullable=True),
        sa.Column('poa', sa.String(length=120), nullable=True),
        sa.Column('poa_phone', sa.String(length=120), nullable=True),
        sa.Column('poa_address1', sa.String(length=120), nullable=True),
        sa.Column('city', sa.String(length=50), nullable=True),
        sa.Column('state', sa.String(length=2), nullable=True),
        sa.Column('zip_code', sa.String(length=10), nullable=True),
        sa.Column('medicare', sa.BINARY(length=255), nullable=True),
        sa.Column('secondary', sa.BINARY(length=255), nullable=True),
        sa.Column('discharge_date', sa.DateTime(), nullable=True),
        sa.Column('notes', sa.String(length=255), nullable=True),
        sa.Column('disc_slp', sa.Boolean(), nullable=True),
        sa.Column('disc_ot', sa.Boolean(), nullable=True),
        sa.Column('disc_pt', sa.Boolean(), nullable=True),
        sa.Column('treat_oral', sa.Boolean(), nullable=True),
        sa.Column('treat_speech', sa.Boolean(), nullable=True),
        sa.Column('treat_cognitive', sa.Boolean(), nullable=True),
        sa.Column('treat_caregiver', sa.Boolean(), nullable=True),
        sa.Column('treat_dementia', sa.Boolean(), nullable=True),
        sa.Column('treat_adl', sa.Boolean(), nullable=True),
        sa.Column('treat_safety', sa.Boolean(), nullable=True),
        sa.Column('treat_upper_extremity', sa.Boolean(), nullable=True),
        sa.Column('treat_ther_exercise', sa.Boolean(), nullable=True),
        sa.Column('treat_balance', sa.Boolean(), nullable=True),
        sa.Column('treat_ther_activity', sa.Boolean(), nullable=True),
        sa.Column('treat_coordination', sa.Boolean(), nullable=True),
        sa.Column('treat_transfer', sa.Boolean(), nullable=True),
        sa.Column('treat_range', sa.Boolean(), nullable=True),
        sa.Column('treat_massage', sa.Boolean(), nullable=True),
        sa.Column('treat_pain', sa.Boolean(), nullable=True),
        sa.Column('treat_wheelchair', sa.Boolean(), nullable=True),
        sa.Column('treat_lower_extremity', sa.Boolean(), nullable=True),
        sa.Column('treat_cane', sa.Boolean(), nullable=True),
        sa.Column('treat_postural', sa.Boolean(), nullable=True),
        sa.Column('treat_gait', sa.Boolean(), nullable=True),
        sa.Column('treat_other', sa.Boolean(), nullable=True),
        sa.Column('treat_other_desc', sa.String(length=120), nullable=True),
        sa.Column('med_type', sa.String(length=50), nullable=True),
        sa.Column('med_firstname', sa.String(length=50), nullable=True),
        sa.Column('med_lastname', sa.String(length=50), nullable=True),
        sa.Column('med_npi', sa.String(length=10), nullable=True),
        sa.Column('med_address1', sa.String(length=120), nullable=True),
        sa.Column('med_address2', sa.String(length=120), nullable=True),
        sa.Column('med_city', sa.String(length=50), nullable=True),
        sa.Column('med_state', sa.String(length=2), nullable=True),
        sa.Column('med_zip_code', sa.String(length=10), nullable=True),
        sa.Column('med_email', sa.String(length=120), nullable=True),
        sa.Column('med_phone', sa.String(length=50), nullable=True),
        sa.Column('med_fax', sa.String(length=50), nullable=True),
        sa.Column('referral_status',
                  sa.String(length=50),
                  autoincrement=True,
                  nullable=True),
        sa.Column('referral_date', sa.DateTime(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.Column('source_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['source_id'],
            ['source.id'],
        ), sa.ForeignKeyConstraint(
            ['user_id'],
            ['user.id'],
        ), sa.PrimaryKeyConstraint('id'))
Ejemplo n.º 29
0
 class UUIDType(sa.types.TypeDecorator):
     python_type = uuid.UUID
     impl = sa.BINARY(16)
def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('ticket_comment', 'file')
    op.create_table('ticket_file',
                    sa.Column('id',
                              mysql.INTEGER(display_width=11),
                              autoincrement=True,
                              nullable=False),
                    sa.Column('ticket_comment_id',
                              mysql.INTEGER(display_width=11),
                              autoincrement=False,
                              nullable=False),
                    sa.Column('attached_file',
                              mysql.VARCHAR(length=200),
                              nullable=False),
                    sa.Column('description', mysql.TEXT(), nullable=True),
                    sa.ForeignKeyConstraint(['ticket_comment_id'],
                                            ['ticket_comment.id'],
                                            name='ticket_file_ibfk_1',
                                            ondelete='CASCADE'),
                    sa.PrimaryKeyConstraint('id'),
                    mysql_default_charset='utf8mb4',
                    mysql_engine='InnoDB')
    op.create_index('id', 'ticket_file', ['id'], unique=True)
    op.create_table('member_project',
                    sa.Column('id',
                              mysql.INTEGER(display_width=11),
                              autoincrement=True,
                              nullable=False),
                    sa.Column('user_id',
                              mysql.INTEGER(display_width=11),
                              autoincrement=False,
                              nullable=False),
                    sa.Column('project_id',
                              mysql.INTEGER(display_width=11),
                              autoincrement=False,
                              nullable=False),
                    sa.ForeignKeyConstraint(['project_id'], ['project.id'],
                                            name='member_project_ibfk_1',
                                            ondelete='CASCADE'),
                    sa.ForeignKeyConstraint(['user_id'], ['user.id'],
                                            name='member_project_ibfk_2',
                                            ondelete='CASCADE'),
                    sa.PrimaryKeyConstraint('id'),
                    mysql_default_charset='utf8mb4',
                    mysql_engine='InnoDB')
    op.create_index('id', 'member_project', ['id'], unique=True)
    op.create_table('job',
                    sa.Column('id',
                              mysql.INTEGER(display_width=11),
                              autoincrement=True,
                              nullable=False),
                    sa.Column('uuid', sa.BINARY(length=16), nullable=False),
                    sa.Column('user_id',
                              mysql.INTEGER(display_width=11),
                              autoincrement=False,
                              nullable=False),
                    sa.ForeignKeyConstraint(['user_id'], ['user.id'],
                                            name='job_ibfk_1',
                                            ondelete='CASCADE'),
                    sa.PrimaryKeyConstraint('id'),
                    mysql_default_charset='utf8mb4',
                    mysql_engine='InnoDB')
    op.create_index('id', 'job', ['id'], unique=True)
    op.create_table('task_team_member',
                    sa.Column('id',
                              mysql.INTEGER(display_width=11),
                              autoincrement=True,
                              nullable=False),
                    sa.Column('team_id',
                              mysql.INTEGER(display_width=11),
                              autoincrement=False,
                              nullable=False),
                    sa.Column('task_id',
                              mysql.INTEGER(display_width=11),
                              autoincrement=False,
                              nullable=False),
                    sa.ForeignKeyConstraint(['task_id'], ['task.id'],
                                            name='task_team_member_ibfk_1',
                                            ondelete='CASCADE'),
                    sa.ForeignKeyConstraint(['team_id'], ['team.id'],
                                            name='task_team_member_ibfk_2',
                                            ondelete='CASCADE'),
                    sa.PrimaryKeyConstraint('id'),
                    mysql_default_charset='utf8mb4',
                    mysql_engine='InnoDB')
    op.create_index('id', 'task_team_member', ['id'], unique=True)
    op.drop_table('rq_job')