Python sqlalchemy.DateTime() Examples

The following are 30 code examples of sqlalchemy.DateTime(). 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: d2aafa234374_create_error_logs_table.py    From backend.ai-manager with GNU Lesser General Public License v3.0 8 votes vote down vote up
def upgrade():
    op.create_table(
        'error_logs',
        IDColumn(),
        sa.Column('created_at', sa.DateTime(timezone=True),
                  server_default=sa.func.now(), index=True),
        sa.Column('severity', sa.Enum('critical', 'error', 'warning', 'info', 'debug', name='errorlog_severity'),
                  index=True),
        sa.Column('source', sa.String),
        sa.Column('user', GUID, sa.ForeignKey('users.uuid'), nullable=True, index=True),
        sa.Column('is_read', sa.Boolean, default=False, index=True),
        sa.Column('is_cleared', sa.Boolean, default=False, index=True),
        sa.Column('message', sa.Text),
        sa.Column('context_lang', sa.String),
        sa.Column('context_env', postgresql.JSONB()),
        sa.Column('request_url', sa.String, nullable=True),
        sa.Column('request_status', sa.Integer, nullable=True),
        sa.Column('traceback', sa.Text, nullable=True),
    ) 
Example #2
Source File: 0f3bc98edaa0_more_status.py    From backend.ai-manager with GNU Lesser General Public License v3.0 7 votes vote down vote up
def upgrade():
    agentstatus.create(op.get_bind())
    kernelstatus.create(op.get_bind())
    op.add_column('agents', sa.Column('lost_at', sa.DateTime(timezone=True), nullable=True))
    op.add_column('agents', sa.Column('status', sa.Enum('ALIVE', 'LOST', 'RESTARTING', 'TERMINATED', name='agentstatus'), nullable=False))
    op.create_index(op.f('ix_agents_status'), 'agents', ['status'], unique=False)
    op.add_column('kernels', sa.Column('agent_addr', sa.String(length=128), nullable=False))
    op.add_column('kernels', sa.Column('cpu_slot', sa.Integer(), nullable=False))
    op.add_column('kernels', sa.Column('gpu_slot', sa.Integer(), nullable=False))
    op.add_column('kernels', sa.Column('mem_slot', sa.Integer(), nullable=False))
    op.add_column('kernels', sa.Column('repl_in_port', sa.Integer(), nullable=False))
    op.add_column('kernels', sa.Column('repl_out_port', sa.Integer(), nullable=False))
    op.add_column('kernels', sa.Column('stdin_port', sa.Integer(), nullable=False))
    op.add_column('kernels', sa.Column('stdout_port', sa.Integer(), nullable=False))
    op.drop_column('kernels', 'allocated_cores')
    op.add_column('kernels', sa.Column('cpu_set', sa.ARRAY(sa.Integer), nullable=True))
    op.add_column('kernels', sa.Column('gpu_set', sa.ARRAY(sa.Integer), nullable=True))
    op.alter_column('kernels', column_name='status', type_=sa.Enum(*kernelstatus_choices, name='kernelstatus'),
                    postgresql_using='status::kernelstatus') 
Example #3
Source File: b6bfca998431_add_container_actions_events_table.py    From zun with Apache License 2.0 6 votes vote down vote up
def upgrade():
    op.create_table(
        'container_actions_events',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('event', sa.String(length=255), nullable=True),
        sa.Column('action_id', sa.Integer(), nullable=False),
        sa.Column('start_time', sa.DateTime(), nullable=True),
        sa.Column('finish_time', sa.DateTime(), nullable=True),
        sa.Column('result', sa.String(length=255), nullable=True),
        sa.Column('traceback', sa.Text(), nullable=True),
        sa.Column('details', sa.Text(), nullable=True),
        sa.ForeignKeyConstraint(['action_id'], ['container_actions.id'], ),
        sa.PrimaryKeyConstraint('id')
    ) 
Example #4
Source File: 15ea3c2cf83d_pr_comment_editing.py    From pagure with GNU General Public License v2.0 6 votes vote down vote up
def upgrade():
    ''' Add the columns editor_id and edited_on to the table
    pull_request_comments.
    '''

    op.add_column(
        'pull_request_comments',
        sa.Column(
            'editor_id',
            sa.Integer,
            sa.ForeignKey('users.id', onupdate='CASCADE'),
            nullable=True)
    )

    op.add_column(
        'pull_request_comments',
        sa.Column(
            'edited_on',
            sa.DateTime,
            nullable=True)
    ) 
Example #5
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 #6
Source File: 9fe371393a24_create_table_container.py    From zun with Apache License 2.0 6 votes vote down vote up
def upgrade():
    op.create_table(
        'container',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('project_id', sa.String(length=255), nullable=True),
        sa.Column('user_id', sa.String(length=255), nullable=True),
        sa.Column('uuid', sa.String(length=36), nullable=True),
        sa.Column('name', sa.String(length=255), nullable=True),
        sa.Column('image', sa.String(length=255), nullable=True),
        sa.Column('command', sa.String(length=255), nullable=True),
        sa.Column('status', sa.String(length=20), nullable=True),
        sa.Column('environment', zun.db.sqlalchemy.models.JSONEncodedDict(),
                  nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('uuid', name='uniq_container0uuid')
    ) 
Example #7
Source File: 3ad36e2268b0_create_collection_replicas_updates_table.py    From rucio with Apache License 2.0 6 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        schema = context.get_context().version_table_schema if context.get_context().version_table_schema else ''
        add_column('collection_replicas', sa.Column('available_replicas_cnt', sa.BigInteger()), schema=schema)
        add_column('collection_replicas', sa.Column('available_bytes', sa.BigInteger()), schema=schema)

        create_table('updated_col_rep',
                     sa.Column('id', GUID()),
                     sa.Column('scope', sa.String(25)),
                     sa.Column('name', sa.String(255)),
                     sa.Column('did_type', DIDType.db_type()),
                     sa.Column('rse_id', GUID()),
                     sa.Column('created_at', sa.DateTime, default=datetime.datetime.utcnow),
                     sa.Column('updated_at', sa.DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow))

        create_primary_key('UPDATED_COL_REP_PK', 'updated_col_rep', ['id'])
        create_check_constraint('UPDATED_COL_REP_SCOPE_NN', 'updated_col_rep', 'scope IS NOT NULL')
        create_check_constraint('UPDATED_COL_REP_NAME_NN', 'updated_col_rep', 'name IS NOT NULL')
        create_index('UPDATED_COL_REP_SNR_IDX', 'updated_col_rep', ['scope', 'name', 'rse_id']) 
Example #8
Source File: a74275a1ad30_added_global_quota_table.py    From rucio with Apache License 2.0 6 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        create_table(table_name,
                     sa.Column('rse_expression', sa.String(3000)),
                     sa.Column('bytes', sa.BigInteger()),
                     sa.Column('account', sa.String(25)),
                     sa.Column('created_at', sa.DateTime, default=datetime.datetime.utcnow),
                     sa.Column('updated_at', sa.DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow))
        create_primary_key('ACCOUNT_GLOB_LIMITS_PK', table_name, ['account', 'rse_expression'])
        create_check_constraint('ACCOUNT_GLOB_LIMITS_CREATED_NN', table_name, 'created_at is not null')
        create_check_constraint('ACCOUNT_GLOB_LIMITS_UPDATED_NN', table_name, 'updated_at is not null')
        create_foreign_key('ACCOUNT_GLOBAL_LIMITS_ACC_FK', table_name, 'accounts', ['account'], ['account']) 
Example #9
Source File: 33cdd98bb9b2_split_volume_mapping_table.py    From zun with Apache License 2.0 6 votes vote down vote up
def create_volume_table():
    op.create_table(
        'volume',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('uuid', sa.String(36), nullable=False),
        sa.Column('project_id', sa.String(length=255), nullable=True),
        sa.Column('user_id', sa.String(length=255), nullable=True),
        sa.Column('cinder_volume_id', sa.String(36), nullable=True),
        sa.Column('volume_provider', sa.String(36), nullable=False),
        sa.Column('connection_info', MediumText(), nullable=True),
        sa.Column('host', sa.String(length=255), nullable=True),
        sa.Column('auto_remove', sa.Boolean(), default=False, nullable=True),
        sa.Column('contents', MediumText(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('uuid', name='uniq_volume0uuid'),
    ) 
Example #10
Source File: a251f1f61217_create_capsule_table.py    From zun with Apache License 2.0 6 votes vote down vote up
def upgrade():
    op.create_table(
        'capsule',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('capsule_version', sa.String(length=255), nullable=True),
        sa.Column('kind', sa.String(length=36), nullable=True),
        sa.Column('project_id', sa.String(length=255), nullable=True),
        sa.Column('user_id', sa.String(length=255), nullable=True),
        sa.Column('restart_policy', sa.String(length=255), nullable=True),
        sa.Column('host_selector', sa.String(length=255), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('uuid', sa.String(length=36), nullable=False),
        sa.Column('status', sa.String(length=255), nullable=True),
        sa.Column('status_reason', sa.Text(), nullable=True),
        sa.Column('message', models.JSONEncodedDict(), nullable=True),
        sa.Column('spec', models.JSONEncodedDict(), nullable=True),
        sa.Column('cpu', sa.Float(), nullable=True),
        sa.Column('memory', sa.String(length=255), nullable=True),
        sa.Column('meta_name', sa.String(length=255), nullable=True),
        sa.Column('meta_labels', models.JSONEncodedList(), nullable=True),
        sa.Column('containers_uuids', models.JSONEncodedList(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
    ) 
Example #11
Source File: 914b8f02df38_new_table_for_lifetime_model_exceptions.py    From rucio with Apache License 2.0 6 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        create_table('lifetime_except',
                     sa.Column('id', GUID()),
                     sa.Column('scope', sa.String(25)),
                     sa.Column('name', sa.String(255)),
                     sa.Column('did_type', DIDType.db_type()),
                     sa.Column('account', sa.String(25)),
                     sa.Column('comments', sa.String(4000)),
                     sa.Column('pattern', sa.String(255)),
                     sa.Column('state', LifetimeExceptionsState.db_type()),
                     sa.Column('created_at', sa.DateTime, default=datetime.datetime.utcnow),
                     sa.Column('updated_at', sa.DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow),
                     sa.Column('expires_at', sa.DateTime))

        create_primary_key('LIFETIME_EXCEPT_PK', 'lifetime_except', ['id', 'scope', 'name', 'did_type', 'account'])
        create_check_constraint('LIFETIME_EXCEPT_SCOPE_NN', 'lifetime_except', 'scope is not null')
        create_check_constraint('LIFETIME_EXCEPT_NAME_NN', 'lifetime_except', 'name is not null')
        create_check_constraint('LIFETIME_EXCEPT_DID_TYPE_NN', 'lifetime_except', 'did_type is not null') 
Example #12
Source File: a13967424130_add_pr_tags_table.py    From pagure with GNU General Public License v2.0 6 votes vote down vote up
def upgrade():
    """ Create the tags_pull_requests to store the tags of pull-requests.
    """
    op.create_table(
        'tags_pull_requests',
        sa.Column(
            'tag_id',
            sa.Integer,
            sa.ForeignKey(
                'tags_colored.id', ondelete='CASCADE', onupdate='CASCADE',
            ),
            primary_key=True),
        sa.Column(
            'request_uid',
            sa.String(32),
            sa.ForeignKey(
                'pull_requests.uid', ondelete='CASCADE', onupdate='CASCADE',
            ),
            primary_key=True),
        sa.Column(
            'date_created',
            sa.DateTime,
            nullable=False,
            default=datetime.datetime.utcnow),
    ) 
Example #13
Source File: cf46a28f46bc_add_container_actions_table.py    From zun with Apache License 2.0 6 votes vote down vote up
def upgrade():
    op.create_table(
        'container_actions',
        sa.Column('created_at', sa.DateTime(), nullable=True),
        sa.Column('updated_at', sa.DateTime(), nullable=True),
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('action', sa.String(length=255), nullable=True),
        sa.Column('container_uuid', sa.String(length=36), nullable=False),
        sa.Column('request_id', sa.String(length=255), nullable=True),
        sa.Column('user_id', sa.String(length=255), nullable=True),
        sa.Column('project_id', sa.String(length=255), nullable=True),
        sa.Column('start_time', sa.DateTime(), nullable=True),
        sa.Column('finish_time', sa.DateTime(), nullable=True),
        sa.Column('message', sa.String(length=255), nullable=True),
        sa.Index('container_uuid_idx', 'container_uuid'),
        sa.Index('request_id_idx', 'request_id'),
        sa.ForeignKeyConstraint(['container_uuid'], ['container.uuid'], ),
        sa.PrimaryKeyConstraint('id')
    ) 
Example #14
Source File: 6190226bed0_add_the_updated_on_column_to_pull_.py    From pagure with GNU General Public License v2.0 6 votes vote down vote up
def upgrade():
    ''' Add the column updated_on to the table pull_requests.
    '''
    op.add_column(
        'pull_requests',
        sa.Column(
            'updated_on',
            sa.DateTime,
            nullable=True,
            default=sa.func.now(),
            onupdate=sa.func.now()
        )
    )

    op.execute('''UPDATE "pull_requests" SET updated_on=date_created;''')

    op.alter_column(
        'pull_requests',
        column_name='updated_on',
        nullable=False,
        existing_nullable=True) 
Example #15
Source File: 4c3a4acfe006_new_attr_account_table.py    From rucio with Apache License 2.0 6 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        create_table('account_attr_map',
                     sa.Column('account', sa.String(25)),
                     sa.Column('key', sa.String(255)),
                     sa.Column('value', sa.String(255)),
                     sa.Column('created_at', sa.DateTime, default=datetime.datetime.utcnow),
                     sa.Column('updated_at', sa.DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow))

        create_primary_key('ACCOUNT_ATTR_MAP_PK', 'account_attr_map', ['account', 'key'])
        create_check_constraint('ACCOUNT_ATTR_MAP_CREATED_NN', 'account_attr_map', 'created_at is not null')
        create_check_constraint('ACCOUNT_ATTR_MAP_UPDATED_NN', 'account_attr_map', 'updated_at is not null')
        create_foreign_key('ACCOUNT_ATTR_MAP_ACCOUNT_FK', 'account_attr_map', 'accounts', ['account'], ['account'])
        create_index('ACCOUNT_ATTR_MAP_KEY_VALUE_IDX', 'account_attr_map', ['key', 'value']) 
Example #16
Source File: ce209920f654_create_task_template_table.py    From backend.ai-manager with GNU Lesser General Public License v3.0 6 votes vote down vote up
def upgrade():
    op.create_table(
        'session_templates',
        IDColumn('id'),
        sa.Column('created_at', sa.DateTime(timezone=True),
                  server_default=sa.func.now(), index=True),
        sa.Column('is_active', sa.Boolean, default=True),
        sa.Column('type',
                  sa.Enum('TASK', 'CLUSTER', name='templatetypes'),
                  nullable=False,
                  server_default='TASK'
                  ),
        sa.Column('domain_name', sa.String(length=64), sa.ForeignKey('domains.name'), nullable=False),
        sa.Column('group_id', GUID, sa.ForeignKey('groups.id'), nullable=True),
        sa.Column('user_uuid', GUID, sa.ForeignKey('users.uuid'), nullable=False),

        sa.Column('name', sa.String(length=128), nullable=True),
        sa.Column('template', sa.String(length=16 * 1024), nullable=False)
    )
    op.add_column(
        'kernels',
        sa.Column('bootstrap_script', sa.String(length=4 * 1024), nullable=True)
    ) 
Example #17
Source File: 379a19b5332d_create_rse_limits_table.py    From rucio with Apache License 2.0 6 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        create_table('rse_transfer_limits',
                     sa.Column('rse_id', GUID()),
                     sa.Column('activity', sa.String(50)),
                     sa.Column('rse_expression', sa.String(3000)),
                     sa.Column('max_transfers', sa.BigInteger),
                     sa.Column('transfers', sa.BigInteger),
                     sa.Column('waitings', sa.BigInteger),
                     sa.Column('created_at', sa.DateTime, default=datetime.datetime.utcnow),
                     sa.Column('updated_at', sa.DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow))

        create_primary_key('RSE_TRANSFER_LIMITS_PK', 'rse_transfer_limits', ['rse_id', 'activity'])
        create_check_constraint('RSE_TRANSFER_LIMITS_CREATED_NN', 'rse_transfer_limits', 'created_at is not null')
        create_check_constraint('RSE_TRANSFER_LIMITS_UPDATED_NN', 'rse_transfer_limits', 'updated_at is not null')
        create_foreign_key('RSE_TRANSFER_LIMITS_RSE_ID_FK', 'rse_transfer_limits', 'rses', ['rse_id'], ['id']) 
Example #18
Source File: 3b441ef4e928_comment_editing_issue.py    From pagure with GNU General Public License v2.0 6 votes vote down vote up
def upgrade():
    ''' Add the columns editor_id and edited_on to the table issue_comments.
    '''

    op.add_column(
        'issue_comments',
        sa.Column(
            'editor_id',
            sa.Integer,
            sa.ForeignKey('users.id', onupdate='CASCADE'),
            nullable=True)
    )

    op.add_column(
        'issue_comments',
        sa.Column(
            'edited_on',
            sa.DateTime,
            nullable=True)
    ) 
Example #19
Source File: 4783c1f49cb4_create_distance_table.py    From rucio with Apache License 2.0 6 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        create_table('distances',
                     sa.Column('src_rse_id', GUID()),
                     sa.Column('dest_rse_id', GUID()),
                     sa.Column('ranking', sa.Integer),
                     sa.Column('agis_distance', sa.Integer),
                     sa.Column('geoip_distance', sa.Integer),
                     sa.Column('created_at', sa.DateTime, default=datetime.datetime.utcnow),
                     sa.Column('updated_at', sa.DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow))

        create_primary_key('DISTANCES_PK', 'distances', ['src_rse_id', 'dest_rse_id'])
        create_foreign_key('DISTANCES_SRC_RSES_FK', 'distances', 'rses', ['src_rse_id'], ['id'])
        create_foreign_key('DISTANCES_DEST_RSES_FK', 'distances', 'rses', ['dest_rse_id'], ['id'])
        create_check_constraint('DISTANCES_CREATED_NN', 'distances', 'created_at is not null')
        create_check_constraint('DISTANCES_UPDATED_NN', 'distances', 'updated_at is not null')
        create_index('DISTANCES_DEST_RSEID_IDX', 'distances', ['dest_rse_id']) 
Example #20
Source File: da5890c2fa1d_.py    From recruit with Apache License 2.0 6 votes vote down vote up
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('cms_user',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('username', sa.String(length=50), nullable=False),
    sa.Column('_password', sa.String(length=150), nullable=False),
    sa.Column('email', sa.String(length=50), nullable=False),
    sa.Column('join_time', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email')
    )
    op.create_table('user',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('username', sa.String(length=50), nullable=False),
    sa.Column('_password', sa.String(length=150), nullable=False),
    sa.Column('email', sa.String(length=50), nullable=False),
    sa.Column('join_time', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email')
    )
    # ### end Alembic commands ### 
Example #21
Source File: 575767d9f89_added_source_history_table.py    From rucio with Apache License 2.0 6 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        create_table('sources_history',
                     sa.Column('request_id', GUID()),
                     sa.Column('scope', sa.String(25)),
                     sa.Column('name', sa.String(255)),
                     sa.Column('rse_id', GUID()),
                     sa.Column('dest_rse_id', GUID()),
                     sa.Column('url', sa.String(2048)),
                     sa.Column('bytes', sa.BigInteger),
                     sa.Column('ranking', sa.Integer()),
                     sa.Column('is_using', sa.Boolean(), default=False))
        schema = context.get_context().version_table_schema if context.get_context().version_table_schema else ''
        add_column('requests', sa.Column('estimated_at', sa.DateTime), schema=schema)
        add_column('requests_history', sa.Column('estimated_at', sa.DateTime), schema=schema) 
Example #22
Source File: 3082b8cef557_add_naming_convention_table_and_closed_.py    From rucio with Apache License 2.0 6 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        schema = context.get_context().version_table_schema if context.get_context().version_table_schema else ''
        add_column('dids', sa.Column('closed_at', sa.DateTime), schema=schema)
        add_column('contents_history', sa.Column('deleted_at', sa.DateTime), schema=schema)
        create_table('naming_conventions',
                     sa.Column('scope', sa.String(SCOPE_LENGTH)),
                     sa.Column('regexp', sa.String(255)),
                     sa.Column('convention_type', KeyType.db_type()),
                     sa.Column('updated_at', sa.DateTime, default=datetime.datetime.utcnow),
                     sa.Column('created_at', sa.DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow))
        create_primary_key('NAMING_CONVENTIONS_PK', 'naming_conventions', ['scope'])
        create_foreign_key('NAMING_CONVENTIONS_SCOPE_FK', 'naming_conventions',
                           'scopes', ['scope'], ['scope'])
        create_check_constraint('NAMING_CONVENTIONS_CREATED_NN', 'naming_conventions',
                                'created_at is not null')
        create_check_constraint('NAMING_CONVENTIONS_UPDATED_NN', 'naming_conventions',
                                'updated_at is not null') 
Example #23
Source File: 102efcf145f4_added_stuck_at_column_to_rules.py    From rucio with Apache License 2.0 5 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        schema = context.get_context().version_table_schema if context.get_context().version_table_schema else ''
        add_column('rules', sa.Column('stuck_at', sa.DateTime), schema=schema) 
Example #24
Source File: 8a5d68f74beb_add_date_modified_for_project.py    From pagure with GNU General Public License v2.0 5 votes vote down vote up
def upgrade():
    ''' Add the column date_modified to the table projects.
    '''
    op.add_column(
        'projects',
        sa.Column('date_modified', sa.DateTime, nullable=True,
                  default=sa.func.now())
    )
    op.execute("UPDATE projects SET date_modified=date_created;")

    op.alter_column(
        'projects',
        column_name='date_modified',
        nullable=False,
        existing_nullable=True) 
Example #25
Source File: 1fc15ab60d43_add_message_history_table.py    From rucio with Apache License 2.0 5 votes vote down vote up
def upgrade():
    '''
    Upgrade the database to this revision
    '''

    if context.get_context().dialect.name in ['oracle', 'mysql', 'postgresql']:
        create_table('messages_history',
                     sa.Column('id', GUID()),
                     sa.Column('created_at', sa.DateTime, default=datetime.datetime.utcnow),
                     sa.Column('updated_at', sa.DateTime, default=datetime.datetime.utcnow, onupdate=datetime.datetime.utcnow),
                     sa.Column('event_type', sa.String(1024)),
                     sa.Column('payload', sa.String(4000))) 
Example #26
Source File: 2b626a16542e_commit_flag.py    From pagure with GNU General Public License v2.0 5 votes vote down vote up
def upgrade():
    ''' Create the commit_flags table. '''

    op.create_table(
        'commit_flags',
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('uid', sa.String(32), unique=True, nullable=False),
        sa.Column('commit_hash', sa.String(40), index=True, nullable=False),
        sa.Column(
            'token_id', sa.String(64),
            sa.ForeignKey('tokens.id'), nullable=False),
        sa.Column(
            'project_id',
            sa.Integer,
            sa.ForeignKey(
                'projects.id', onupdate='CASCADE', ondelete='CASCADE',
            ),
            nullable=False, index=True),
        sa.Column(
            'user_id', sa.Integer,
            sa.ForeignKey('users.id', onupdate='CASCADE'),
            nullable=False, index=True),
        sa.Column('status', sa.String(32), nullable=False),
        sa.Column('username', sa.Text(), nullable=False),
        sa.Column('percent', sa.Integer(), nullable=True),
        sa.Column('comment', sa.Text(), nullable=False),
        sa.Column('url', sa.Text(), nullable=False),
        sa.Column(
            'date_created', sa.DateTime, nullable=False,
            default=datetime.datetime.utcnow),
    )

    op.create_unique_constraint(
        "commit_flags_uid_commit_hash_key",
        'commit_flags',
        ["uid", "commit_hash"]
    ) 
Example #27
Source File: 5bb80aeb238d_refuse_sessions_before.py    From pagure with GNU General Public License v2.0 5 votes vote down vote up
def upgrade():
    ''' Add the column _reports to the table projects
    '''
    op.add_column(
        'users',
        sa.Column(
            'refuse_sessions_before', sa.DateTime, nullable=True,
            server_default=None)
    ) 
Example #28
Source File: 8a3b10926153_create_deploy_keys_table.py    From pagure with GNU General Public License v2.0 5 votes vote down vote up
def upgrade():
    op.create_table('deploykeys',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('project_id', sa.Integer(), nullable=True),
        sa.Column('pushaccess', sa.Boolean(), nullable=False),
        sa.Column('public_ssh_key', sa.Text(), nullable=False),
        sa.Column('ssh_short_key', sa.Text(), nullable=False),
        sa.Column('ssh_search_key', sa.Text(), nullable=False),
        sa.Column('creator_user_id', sa.Integer(), nullable=False),
        sa.Column('date_created', sa.DateTime(), nullable=False),
        sa.ForeignKeyConstraint(['creator_user_id'], ['users.id'], name=op.f('deploykeys_creator_user_id_fkey'), onupdate='CASCADE'),
        sa.ForeignKeyConstraint(['project_id'], ['projects.id'], name=op.f('deploykeys_project_id_fkey'), onupdate='CASCADE', ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id', name=op.f('deploykeys_pkey'))
    )
    op.create_index(op.f('ix_deploykeys_deploykeys_creator_user_id'), 'deploykeys', ['creator_user_id'], unique=False) 
Example #29
Source File: e3cc5aedb8bb_add_date_updated_to_pr_flags.py    From pagure with GNU General Public License v2.0 5 votes vote down vote up
def upgrade():
    """ Add date_updated column to pull_request_flags table """
    op.add_column(
        'pull_request_flags',
        sa.Column(
            'date_updated',
            sa.DateTime,
            nullable=True,
            default=datetime.datetime.utcnow,
        )
    )
    op.execute('UPDATE pull_request_flags SET date_updated=date_created')
    op.alter_column(
        'pull_request_flags', 'date_updated', existing_type=sa.DateTime,
        nullable=False, existing_nullable=True) 
Example #30
Source File: 7a82e0c70122_add_group_model.py    From backend.ai-manager with GNU Lesser General Public License v3.0 5 votes vote down vote up
def upgrade():
    op.create_table(
        'groups',
        sa.Column('id', GUID(), server_default=sa.text('uuid_generate_v4()'), nullable=False),
        sa.Column('name', sa.String(length=64), nullable=False),
        sa.Column('description', sa.String(length=512), nullable=True),
        sa.Column('is_active', sa.Boolean(), nullable=True),
        sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
        sa.Column('modified_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
        sa.Column('domain_name', sa.String(length=64), nullable=False),
        sa.ForeignKeyConstraint(['domain_name'], ['domains.name'],
                                name=op.f('fk_groups_domain_name_domains'),
                                onupdate='CASCADE', ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id', name=op.f('pk_groups')),
        sa.UniqueConstraint('name', 'domain_name', name='uq_groups_name_domain_name')
    )
    op.create_index(op.f('ix_groups_domain_name'), 'groups', ['domain_name'], unique=False)
    op.create_table(
        'association_groups_users',
        sa.Column('user_id',  GUID(), nullable=False),
        sa.Column('group_id', GUID(), nullable=False),
        sa.ForeignKeyConstraint(['group_id'], ['groups.id'],
                                name=op.f('fk_association_groups_users_group_id_groups'),
                                onupdate='CASCADE', ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['user_id'], ['users.uuid'],
                                name=op.f('fk_association_groups_users_user_id_users'),
                                onupdate='CASCADE', ondelete='CASCADE'),
        sa.UniqueConstraint('user_id', 'group_id', name='uq_association_user_id_group_id')
    )