How to use the alembic.op.create_table function in alembic

To help you get started, we’ve selected a few alembic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github assembl / assembl / assembl / alembic / versions / bf6d8d4d2aff_add_gauge_tables.py View on Github external
def upgrade(pyramid_env):
    with context.begin_transaction():
        op.create_table(
            'gauge_choice_specification',
            sa.Column('id', sa.Integer, primary_key=True),
            sa.Column('value', sa.Float),
            sa.Column('label_id', sa.Integer, sa.ForeignKey('langstring.id')),
            sa.Column(
                'vote_specification_id',
                sa.Integer,
                sa.ForeignKey('vote_specification.id', ondelete='CASCADE', onupdate='CASCADE'),
                nullable=False, index=True)
        )
        op.create_table(
            'number_gauge_vote_specification',
            sa.Column(
                'id', sa.Integer,
                sa.ForeignKey('vote_specification.id', ondelete='CASCADE', onupdate='CASCADE'),
                primary_key=True),
github cjoftheweb / memstash / memstash / migrations / versions / 3c1521d305c6_add_users_and_notes.py View on Github external
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('users',
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('username', sa.Unicode(length=64), nullable=False),
    sa.Column('password', sa.Unicode(length=80), nullable=False),
    sa.PrimaryKeyConstraint('username')
    )
    op.create_table('notes',
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('updated_at', sa.DateTime(), nullable=True),
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('text', sa.UnicodeText(), nullable=False),
    sa.Column('public', sa.Boolean(), nullable=False),
    sa.Column('username', sa.Unicode(length=64), nullable=False),
    sa.ForeignKeyConstraint(['username'], ['users.username'], name='notes_author_fkey'),
    sa.PrimaryKeyConstraint('id')
    )
github Net-ng / kansha / kansha / alembic / versions / f058ce7ee0c_data_in_extensions.py View on Github external
def upgrade():
    bind = op.get_bind()
    is_sqlite = bind.engine.name == 'sqlite'

    op.create_table('card_description',
                    sa.Column('id', sa.Integer, primary_key=True, autoincrement=True),
                    sa.Column('description', sa.UnicodeText, default=lambda: u''),
                    sa.Column('card_id', sa.Integer, sa.ForeignKey('card.id', ondelete='CASCADE')))
    op.create_table('card_due_date',
                    sa.Column('id', sa.Integer, primary_key=True, autoincrement=True),
                    sa.Column('due_date', sa.Date),
                    sa.Column('card_id', sa.Integer, sa.ForeignKey('card.id', ondelete='CASCADE')))
    op.create_table('card_weight',
                    sa.Column('id', sa.Integer, primary_key=True, autoincrement=True),
                    sa.Column('weight', sa.Unicode(255), default=lambda: u''),
                    sa.Column('card_id', sa.Integer, sa.ForeignKey('card.id', ondelete='CASCADE')))
    descriptions = []
    due_dates = []
    weights = []
    descriptions_table = sa.Table(
        'card_description',
        sa.MetaData(),
        sa.Column('id', sa.Integer, primary_key=True, autoincrement=True),
        sa.Column('description', sa.UnicodeText, default=lambda: u''),
        sa.Column('card_id', sa.Integer, sa.ForeignKey('card.id', ondelete='CASCADE'))
    )
    due_dates_table = sa.Table(
        'card_due_date',
        sa.MetaData(),
github joshfriend / flask-restful-demo / migrations / versions / 1aef3e1e33a2_create_user_and_task_tables.py View on Github external
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(), nullable=False),
    sa.Column('email', sa.String(), nullable=False),
    sa.Column('password_hash', sa.String(), nullable=False),
    sa.Column('first_name', sa.String(), nullable=True),
    sa.Column('last_name', sa.String(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email'),
    sa.UniqueConstraint('username')
    )
    op.create_table('tasks',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('complete', sa.Boolean(), nullable=True),
    sa.Column('summary', sa.String(), nullable=True),
    sa.Column('description', sa.String(), nullable=True),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
github fedspendingtransparency / data-act-broker-backend / dataactcore / migrations / versions / 6015ec0f59c9_init_database.py View on Github external
sa.Column('agency', sa.Text(), nullable=True),
    sa.Column('title', sa.Text(), nullable=True),
    sa.Column('permissions', sa.Integer(), nullable=True),
    sa.Column('user_status_id', sa.Integer(), nullable=True),
    sa.Column('password_hash', sa.Text(), nullable=True),
    sa.Column('salt', sa.Text(), nullable=True),
    sa.ForeignKeyConstraint(['user_status_id'], ['user_status.user_status_id'], ),
    sa.PrimaryKeyConstraint('user_id')
    )
    op.create_table('email_template_type',
    sa.Column('email_template_type_id', sa.Integer(), nullable=False),
    sa.Column('name', sa.Text(), nullable=True),
    sa.Column('description', sa.Text(), nullable=True),
    sa.PrimaryKeyConstraint('email_template_type_id')
    )
    op.create_table('email_template',
    sa.Column('email_template_id', sa.Integer(), nullable=False),
    sa.Column('template_type_id', sa.Integer(), nullable=True),
    sa.Column('subject', sa.Text(), nullable=True),
    sa.Column('content', sa.Text(), nullable=True),
    sa.ForeignKeyConstraint(['template_type_id'], ['email_template_type.email_template_type_id']),
    sa.PrimaryKeyConstraint('email_template_id')
    )
    op.create_table('email_token',
    sa.Column('email_token_id', sa.Integer(), nullable=False),
    sa.Column('token', sa.Text(), nullable=True),
    sa.Column('salt', sa.Text(), nullable=True),
    sa.PrimaryKeyConstraint('email_token_id')
    )
github dropbox / changes / migrations / versions / 3f6a69c14037_create_jobstep_command_table.py View on Github external
def upgrade():
    op.create_table(
        'command',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('jobstep_id', sa.GUID(), nullable=False),
        sa.Column('label', sa.String(length=128), nullable=False),
        sa.Column('status', sa.Enum(), nullable=False),
        sa.Column('return_code', sa.Integer(), nullable=False),
        sa.Column('script', sa.Text(), nullable=False),
        sa.Column('env', sa.String(length=2048), nullable=True),
        sa.Column('cwd', sa.String(length=256), nullable=True),
        sa.Column('artifacts', postgresql.ARRAY(sa.String(length=256)), nullable=True),
        sa.Column('date_started', sa.DateTime(), nullable=True),
        sa.Column('date_finished', sa.DateTime(), nullable=True),
        sa.Column('date_created', sa.DateTime(), nullable=True),
        sa.Column('data', sa.JSONEncodedDict(), nullable=True),
        sa.ForeignKeyConstraint(['jobstep_id'], ['jobstep.id'], ),
        sa.PrimaryKeyConstraint('id')
github intel-ctrlsys / sensys / contrib / database / schema_migration / versions / 3f96c40b580a_created_event_schema.py View on Github external
"'%s' is not a supported database dialect." % db_dialect.name)
        return

    op.drop_column('data_sample_raw', 'app_value_type_id')
    op.drop_column('data_sample_raw', 'event_id')
    op.drop_column('data_sample_raw', 'data_sample_id')
    op.drop_table('event_data')
    op.drop_table('event_data_key')
    op.drop_table('event')
    op.create_table('event_type',
                    sa.Column('event_type_id', sa.INTEGER(), nullable=False),
                    sa.Column('name', sa.VARCHAR(length=250),
                              autoincrement=False, nullable=True),
                    sa.PrimaryKeyConstraint('event_type_id',
                                            name=op.f('pk_event_type')))
    op.create_table('event',
                    sa.Column('node_id', sa.Integer(), nullable=False),
                    sa.Column('event_type_id', sa.Integer(), nullable=False),
                    sa.Column('time_stamp', sa.DateTime(), nullable=False),
                    sa.Column('description', sa.Text(), nullable=False),
                    sa.ForeignKeyConstraint(['event_type_id'],
                                            ['event_type.event_type_id'],
                                            name=op.f(
                                                'fk_event_event_type_id_event_type')),
                    sa.ForeignKeyConstraint(['node_id'], ['node.node_id'],
                                            name=op.f('fk_event_node_id_node')),
                    sa.PrimaryKeyConstraint('node_id', 'event_type_id',
                                            'time_stamp',
                                            name=op.f('pk_event')))
github beaker-project / beaker / Server / bkr / server / alembic / versions / 49a4a1e3779a_014_to_015.py View on Github external
def downgrade():
    # System access policies
    op.drop_table('system_access_policy_rule')
    op.drop_table('system_access_policy')

    # TurboGears Visit framework
    op.create_table('visit',
        sa.Column('visit_key', sa.String(40), primary_key=True),
        sa.Column('created', sa.DateTime, nullable=False),
        sa.Column('expiry', sa.DateTime),
        mysql_engine='InnoDB'
    )
    op.create_table('visit_identity',
        sa.Column('visit_key', sa.String(40), primary_key=True),
        sa.Column('user_id', sa.Integer,
            sa.ForeignKey('tg_user.user_id'), nullable=False),
        sa.Column('proxied_by_user_id', sa.Integer,
            sa.ForeignKey('tg_user.user_id')),
        mysql_engine='InnoDB'
    )

    # Group name length
    op.alter_column('tg_group', 'group_name',
github avilaton / gtfseditor / migrations / versions / 13136577df89_first_migration.py View on Github external
sa.Column('monday', sa.String(length=50), nullable=True),
    sa.Column('tuesday', sa.String(length=50), nullable=True),
    sa.Column('wednesday', sa.String(length=50), nullable=True),
    sa.Column('thursday', sa.String(length=50), nullable=True),
    sa.Column('friday', sa.String(length=50), nullable=True),
    sa.Column('saturday', sa.String(length=50), nullable=True),
    sa.Column('sunday', sa.String(length=50), nullable=True),
    sa.PrimaryKeyConstraint('service_id')
    )
    op.create_table('transfers',
    sa.Column('from_stop_id', sa.Integer(), nullable=False),
    sa.Column('to_stop_id', sa.Integer(), nullable=True),
    sa.Column('transfer_type', sa.String(length=50), nullable=True),
    sa.PrimaryKeyConstraint('from_stop_id')
    )
    op.create_table('fare_rules',
    sa.Column('fare_id', sa.String(length=50), nullable=False),
    sa.Column('route_id', sa.Integer(), nullable=True),
    sa.Column('origin_id', sa.String(length=50), nullable=True),
    sa.Column('destination_id', sa.String(length=50), nullable=True),
    sa.Column('contains_id', sa.String(length=50), nullable=True),
    sa.PrimaryKeyConstraint('fare_id')
    )
    op.create_table('users',
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('password', sa.String(length=10), nullable=True),
    sa.Column('email', sa.String(length=50), nullable=True),
    sa.Column('registered_on', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('user_id')
    )
    op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True)
    op.create_table('shapes',
github Weasyl / weasyl / libweasyl / libweasyl / alembic / versions / abac1922735d_squash_revisions_for_publication.py View on Github external
op.create_table('useralias',
    sa.Column('userid', sa.Integer(), nullable=False),
    sa.Column('alias_name', sa.String(length=40), nullable=False),
    sa.Column('settings', sa.String(), server_default='', nullable=False),
    sa.ForeignKeyConstraint(['userid'], ['login.userid'], name='useralias_userid_fkey', onupdate='CASCADE', ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('userid', 'alias_name')
    )
    op.create_table('userinfo',
    sa.Column('userid', sa.Integer(), nullable=False),
    sa.Column('birthday', libweasyl.models.helpers.WeasylTimestampColumn(), nullable=False),
    sa.Column('gender', sa.String(length=25), server_default='', nullable=False),
    sa.Column('country', sa.String(length=50), server_default='', nullable=False),
    sa.ForeignKeyConstraint(['userid'], ['login.userid'], name='userinfo_userid_fkey', onupdate='CASCADE', ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('userid')
    )
    op.create_table('userpremium',
    sa.Column('userid', sa.Integer(), nullable=False),
    sa.Column('unixtime', libweasyl.models.helpers.WeasylTimestampColumn(), nullable=False),
    sa.Column('terms', sa.SMALLINT(), nullable=False),
    sa.ForeignKeyConstraint(['userid'], ['login.userid'], name='userpremium_userid_fkey', onupdate='CASCADE', ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('userid')
    )
    op.create_table('userstats',
    sa.Column('userid', sa.Integer(), nullable=False),
    sa.Column('page_views', sa.Integer(), server_default='0', nullable=False),
    sa.Column('submit_views', sa.Integer(), server_default='0', nullable=False),
    sa.Column('followers', sa.Integer(), server_default='0', nullable=False),
    sa.Column('faved_works', sa.Integer(), server_default='0', nullable=False),
    sa.Column('journals', sa.Integer(), server_default='0', nullable=False),
    sa.Column('submits', sa.Integer(), server_default='0', nullable=False),
    sa.Column('characters', sa.Integer(), server_default='0', nullable=False),
    sa.Column('collects', sa.Integer(), server_default='0', nullable=False),