sqlalchemy.GUID

Here are the examples of the python api sqlalchemy.GUID taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

54 Examples 7

Example 1

View license
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'itemoption',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('item_id', sa.GUID(), nullable=False),
        sa.Column('name', sa.String(length=64), nullable=False),
        sa.Column('value', sa.Text(), nullable=False),
        sa.Column('date_created', sa.DateTime(), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('item_id', 'name', name='unq_itemoption_name')
    )

Example 2

View license
def upgrade():
    op.create_table('buildmessage',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('build_id', sa.GUID(), nullable=False),
        sa.Column('text', sa.Text(), nullable=False),
        sa.Column('date_created', sa.DateTime(), nullable=False),
        sa.ForeignKeyConstraint(['build_id'], ['build.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id')
    )
    op.create_table('bazeltargetmessage',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('target_id', sa.GUID(), nullable=False),
        sa.Column('text', sa.Text(), nullable=False),
        sa.Column('date_created', sa.DateTime(), nullable=False),
        sa.ForeignKeyConstraint(['target_id'], ['bazeltarget.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id')
    )

Example 3

View license
def upgrade():
    op.create_table(
        'itemstat',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('item_id', sa.GUID(), nullable=False),
        sa.Column('name', sa.String(length=64), nullable=False),
        sa.Column('value', sa.Integer(), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('item_id', 'name', name='unq_itemstat_name')
    )

Example 4

View license
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('repositoryoption',
    sa.Column('id', sa.GUID(), nullable=False),
    sa.Column('repository_id', sa.GUID(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=False),
    sa.Column('value', sa.Text(), nullable=False),
    sa.Column('date_created', sa.DateTime(), nullable=False),
    sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('repository_id','name', name='unq_repositoryoption_name')
    )

Example 5

View license
def upgrade():
    op.create_table(
        'testmessage',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('test_id', sa.GUID(), nullable=False),
        sa.Column('artifact_id', sa.GUID(), nullable=False),
        sa.Column('start_offset', sa.Integer(), nullable=False),
        sa.Column('length', sa.Integer(), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        sa.ForeignKeyConstraint(['test_id'], ['test.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['artifact_id'], ['artifact.id'], ondelete='CASCADE'),
    )
    op.create_index('idx_testmessage_test_id', 'testmessage', ['test_id'], unique=False)

Example 6

View license
def upgrade():
    op.create_table(
        'systemoption',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('name', sa.String(length=64), nullable=False),
        sa.Column('value', sa.Text(), nullable=False),
        sa.Column('date_created', sa.DateTime(), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('name')
    )

Example 7

View license
def upgrade():
    op.create_table(
        'latest_green_build',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('project_id', sa.GUID(), nullable=False),
        sa.Column('branch', sa.String(length=128), nullable=False),
        sa.Column('build_id', sa.GUID(), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
        sa.ForeignKeyConstraint(['build_id'], ['build.id'], ),
        sa.UniqueConstraint('project_id', 'branch', name='unq_project_branch')
    )

Example 8

View license
def upgrade():
    op.create_table('flakyteststat',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('name', sa.Text(), nullable=False),
        sa.Column('project_id', sa.GUID(), nullable=False),
        sa.Column('end_date', sa.Date(), nullable=False),
        sa.Column('last_flaky_run_id', sa.GUID(), nullable=False),
        sa.Column('flaky_runs', sa.Integer(), nullable=False),
        sa.Column('passing_runs', sa.Integer(), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        sa.ForeignKeyConstraint(['project_id'], ['project.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['last_flaky_run_id'], ['test.id'], ondelete='CASCADE'),
        sa.UniqueConstraint('name', 'project_id', 'end_date', name='unq_name_per_project_per_day'))
    op.create_index('idx_flakyteststat_end_date', 'flakyteststat', ['end_date'])

Example 9

View license
def upgrade():
    op.create_table(
        'projectoption',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('project_id', sa.GUID(), nullable=False),
        sa.Column('name', sa.String(length=64), nullable=False),
        sa.Column('value', sa.Text(), nullable=False),
        sa.Column('date_created', sa.DateTime(), nullable=False),
        sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('project_id', 'name', name='unq_projectoption_name')
    )

Example 10

View license
def upgrade():
    op.create_table('itemsequence',
        sa.Column('parent_id', sa.GUID(), nullable=False),
        sa.Column('value', sa.Integer(), server_default='1', nullable=False),
        sa.PrimaryKeyConstraint('parent_id', 'value')
    )
    op.execute(NEXT_ITEM_VALUE_FUNCTION)
    op.execute(ADD_BUILD_SEQUENCES)
    op.execute(ADD_JOB_SEQUENCES)

Example 11

View license
def upgrade():
    op.create_table(
        'snapshot',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('project_id', sa.GUID(), nullable=False),
        sa.Column('build_id', sa.GUID(), nullable=True),
        sa.Column('status', sa.Enum(), server_default='0', nullable=False),
        sa.ForeignKeyConstraint(['build_id'], ['build.id'], ),
        sa.ForeignKeyConstraint(['project_id'], ['project.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id')
    )

Example 12

View license
def upgrade():
    op.create_table(
        'buildseen',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('build_id', sa.GUID(), nullable=False),
        sa.Column('user_id', sa.GUID(), nullable=False),
        sa.Column('date_created', sa.DateTime(), nullable=False),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('build_id', 'user_id', name='unq_buildseen_entity')
    )
    op.create_foreign_key('buildseen_build_id_fkey', 'buildseen', 'build', ['build_id'], ['id'], ondelete='CASCADE')
    op.create_foreign_key('buildseen_user_id_fkey', 'buildseen', 'user', ['user_id'], ['id'], ondelete='CASCADE')

Example 13

View license
def upgrade():
    op.create_table(
        'cached_snapshot_image',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('expiration_date', sa.DateTime(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.ForeignKeyConstraint(['id'], ['snapshot_image.id'], ondelete='CASCADE'),
    )

    # We do a lot of comparison queries on the expiration date so
    # we require an index here for efficient operations
    op.create_index('idx_cached_snapshot_image_expiration_date', 'cached_snapshot_image', ['expiration_date'])

Example 14

View license
def upgrade():
    op.create_table(
        'bazeltarget',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('step_id', sa.GUID(), nullable=False),
        sa.Column('job_id', sa.GUID(), nullable=False),
        sa.Column('name', sa.Text(), nullable=False),
        sa.Column('status', sa.Enum(), nullable=False),
        sa.Column('result', sa.Enum(), nullable=False),
        sa.Column('duration', sa.Integer(), nullable=True),
        sa.Column('date_created', sa.DateTime(), nullable=False),
        sa.ForeignKeyConstraint(
            ['step_id'], ['jobstep.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(
            ['job_id'], ['job.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id')
    )

Example 15

View license
def upgrade():
    op.create_table('adminmessage',
                    sa.Column('id', sa.GUID(), nullable=False),
                    sa.Column('user_id', sa.GUID(), nullable=True),
                    sa.Column('date_created', sa.DateTime(), nullable=True),
                    sa.Column('message', sa.Text(), nullable=True),
                    sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
                    sa.PrimaryKeyConstraint('id'))

Example 16

Project: changes
Source File: 2c380be0a31e_add_event.py
View license
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'event',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('type', sa.String(length=32), nullable=False),
        sa.Column('item_id', sa.GUID(), nullable=False),
        sa.Column('date_created', sa.DateTime(), nullable=True),
        sa.Column('date_modified', sa.DateTime(), nullable=True),
        sa.Column('data', sa.JSONEncodedDict(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('type', 'item_id', name='unq_event_key')
    )

Example 17

Project: changes
Source File: 2c7cbd9b7e54_add_source.py
View license
def upgrade():
    op.create_table(
        'source',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('repository_id', sa.GUID(), nullable=False),
        sa.Column('patch_id', sa.GUID(), nullable=True),
        sa.Column('revision_sha', sa.String(length=40), nullable=True),
        sa.Column('date_created', sa.DateTime(), nullable=True),
        sa.ForeignKeyConstraint(['patch_id'], ['patch.id']),
        sa.ForeignKeyConstraint(['repository_id'], ['repository.id']),
        sa.PrimaryKeyConstraint('id')
    )
    op.add_column('build', sa.Column('source_id', sa.GUID(), nullable=True))
    op.add_column('buildfamily', sa.Column('source_id', sa.GUID(), nullable=True))
    op.create_index('idx_build_source_id', 'build', ['source_id'])
    op.create_index('idx_buildfamily_source_id', 'buildfamily', ['source_id'])

Example 18

View license
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'snapshot_image',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('snapshot_id', sa.GUID(), nullable=False),
        sa.Column('plan_id', sa.GUID(), nullable=False),
        sa.Column('job_id', sa.GUID(), nullable=True, unique=True),
        sa.Column('date_created', sa.DateTime(), nullable=False),
        sa.ForeignKeyConstraint(['job_id'], ['job.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['plan_id'], ['plan.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['snapshot_id'], ['snapshot.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('snapshot_id', 'plan_id', name='unq_snapshotimage_plan')
    )

    op.create_unique_constraint(None, 'snapshot', ['build_id'])

Example 19

View license
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'phabricatordiff',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('diff_id', sa.Integer(), nullable=True),
        sa.Column('revision_id', sa.Integer(), nullable=True),
        sa.Column('source_id', sa.GUID(), nullable=True),
        sa.Column('url', sa.String(), nullable=True),
        sa.Column('date_created', sa.DateTime(), nullable=True),
        sa.ForeignKeyConstraint(['source_id'], ['source.id'], ),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('diff_id')
    )

Example 20

View license
def upgrade():
    op.create_table(
        'project_plan',
        sa.Column('project_id', sa.GUID(), nullable=False),
        sa.Column('plan_id', sa.GUID(), nullable=False),
        sa.ForeignKeyConstraint(['plan_id'], ['plan.id'], ),
        sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
        sa.PrimaryKeyConstraint('project_id', 'plan_id')
    )

Example 21

View license
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')
    )

Example 22

View license
def upgrade():
    op.create_table(
        'testartifact',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('test_id', sa.GUID(), nullable=False),
        sa.Column('name', sa.String(length=256), nullable=False),
        sa.Column('type', sa.Enum(), server_default='0', nullable=False),
        sa.Column('file', sa.FileStorage(), nullable=True),
        sa.Column('date_created', sa.DateTime(), nullable=True),

        sa.ForeignKeyConstraint(['test_id'], ['test.id'], ),
        sa.PrimaryKeyConstraint('id'),

        sa.Index('idx_test_id', 'test_id'),
    )

Example 23

View license
def upgrade():
    op.create_table(
        'artifact',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('job_id', sa.GUID(), nullable=False),
        sa.Column('step_id', sa.GUID(), nullable=False),
        sa.Column('project_id', sa.GUID(), nullable=False),
        sa.Column('name', sa.String(length=128), nullable=False),
        sa.Column('date_created', sa.DateTime(), nullable=True),
        sa.Column('data', sa.JSONEncodedDict(), nullable=True),
        sa.ForeignKeyConstraint(['job_id'], ['job.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['project_id'], ['project.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['step_id'], ['jobstep.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('step_id', 'name', name='unq_artifact_name'),
    )

Example 24

Project: changes
Source File: 5677ef75c712_add_user.py
View license
def upgrade():
    op.create_table(
        'user',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('email', sa.String(length=128), nullable=False),
        sa.Column('is_admin', sa.Boolean(), nullable=False),
        sa.Column('date_created', sa.DateTime(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('email')
    )

Example 25

Project: changes
Source File: 586238e1375a_add_comment.py
View license
def upgrade():
    op.create_table(
        'comment',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('build_id', sa.GUID(), nullable=False),
        sa.Column('user_id', sa.GUID(), nullable=False),
        sa.Column('job_id', sa.GUID(), nullable=True),
        sa.Column('text', sa.Text(), nullable=True),
        sa.Column('date_created', sa.DateTime(), nullable=True),
        sa.ForeignKeyConstraint(['build_id'], ['build.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['job_id'], ['job.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['user_id'], ['user.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id')
    )

Example 26

View license
def upgrade():
    op.add_column('aggtestgroup', sa.Column('last_build_id', sa.GUID()))
    op.add_column('aggtestsuite', sa.Column('last_build_id', sa.GUID()))

    op.execute("update aggtestgroup set last_build_id = first_build_id where first_build_id is null")
    op.execute("update aggtestsuite set last_build_id = first_build_id where first_build_id is null")

    op.alter_column('aggtestgroup', sa.Column('last_build_id', sa.GUID(), nullable=False))
    op.alter_column('aggtestsuite', sa.Column('last_build_id', sa.GUID(), nullable=False))

Example 27

View license
def upgrade():
    op.create_table(
        'buildphase',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('build_id', sa.GUID(), nullable=False),
        sa.Column('repository_id', sa.GUID(), nullable=False),
        sa.Column('project_id', sa.GUID(), nullable=False),
        sa.Column('label', sa.String(length=128), nullable=False),
        sa.Column('status', sa.Enum(), nullable=False),
        sa.Column('result', sa.Enum(), nullable=False),
        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.ForeignKeyConstraint(['build_id'], ['build.id'], ),
        sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
        sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], ),
        sa.PrimaryKeyConstraint('id')
    )
    op.create_table(
        'buildstep',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('build_id', sa.GUID(), nullable=False),
        sa.Column('phase_id', sa.GUID(), nullable=False),
        sa.Column('repository_id', sa.GUID(), nullable=False),
        sa.Column('project_id', sa.GUID(), nullable=False),
        sa.Column('label', sa.String(length=128), nullable=False),
        sa.Column('status', sa.Enum(), nullable=False),
        sa.Column('result', sa.Enum(), nullable=False),
        sa.Column('node_id', sa.GUID(), 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.ForeignKeyConstraint(['build_id'], ['build.id'], ),
        sa.ForeignKeyConstraint(['node_id'], ['node.id'], ),
        sa.ForeignKeyConstraint(['phase_id'], ['buildphase.id'], ),
        sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
        sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], ),
        sa.PrimaryKeyConstraint('id')
    )
    op.drop_table(u'step')
    op.drop_table(u'phase')

Example 28

View license
def upgrade():
    op.create_table(
        'aggtestsuite',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('project_id', sa.GUID(), nullable=False),
        sa.Column('name_sha', sa.String(length=40), nullable=False),
        sa.Column('name', sa.Text(), nullable=False),
        sa.Column('first_build_id', sa.GUID(), nullable=False),
        sa.Column('date_created', sa.DateTime(), nullable=False),
        sa.ForeignKeyConstraint(['first_build_id'], ['build.id'], ),
        sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint(
            'project_id', 'name_sha', name='unq_aggtestsuite_key')
    )
    op.create_index('idx_aggtestsuite_first_build_id', 'aggtestsuite', ['first_build_id'])

    op.create_table(
        'aggtestgroup',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('project_id', sa.GUID(), nullable=False),
        sa.Column('suite_id', sa.GUID(), nullable=True),
        sa.Column('parent_id', sa.GUID(), nullable=True),
        sa.Column('name_sha', sa.String(length=40), nullable=False),
        sa.Column('name', sa.Text(), nullable=False),
        sa.Column('first_build_id', sa.GUID(), nullable=False),
        sa.Column('date_created', sa.DateTime(), nullable=False),
        sa.ForeignKeyConstraint(['first_build_id'], ['build.id'], ),
        sa.ForeignKeyConstraint(['parent_id'], ['aggtestgroup.id'], ),
        sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
        sa.ForeignKeyConstraint(['suite_id'], ['aggtestsuite.id'], ),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint(
            'project_id', 'suite_id', 'name_sha', name='unq_aggtestgroup_key')
    )
    op.create_index('idx_aggtestgroup_suite_id', 'aggtestgroup', ['suite_id'])
    op.create_index('idx_aggtestgroup_parent_id', 'aggtestgroup', ['parent_id'])
    op.create_index('idx_aggtestgroup_first_build_id', 'aggtestgroup', ['first_build_id'])

Example 29

View license
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'cluster',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('label', sa.String(length=128), nullable=True),
        sa.Column('date_created', sa.DateTime(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('label')
    )
    op.create_table(
        'cluster_node',
        sa.Column('cluster_id', sa.GUID(), nullable=False),
        sa.Column('node_id', sa.GUID(), nullable=False),
        sa.Column('date_created', sa.DateTime(), nullable=True),
        sa.ForeignKeyConstraint(['cluster_id'], ['cluster.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['node_id'], ['node.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('cluster_id', 'node_id')
    )
    op.add_column('node', sa.Column('data', sa.JSONEncodedDict(), nullable=True))

Example 30

View license
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'failurereason',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('step_id', sa.GUID(), nullable=False),
        sa.Column('job_id', sa.GUID(), nullable=False),
        sa.Column('build_id', sa.GUID(), nullable=False),
        sa.Column('project_id', sa.GUID(), nullable=False),
        sa.Column('reason', sa.String(length=32), nullable=False),
        sa.Column('date_created', sa.DateTime(), nullable=False),
        sa.ForeignKeyConstraint(['build_id'], ['build.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['job_id'], ['job.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['project_id'], ['project.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['step_id'], ['jobstep.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('step_id', 'reason', name='unq_failurereason_key')
    )
    op.create_index('idx_failurereason_build_id', 'failurereason', ['build_id'], unique=False)
    op.create_index('idx_failurereason_job_id', 'failurereason', ['job_id'], unique=False)
    op.create_index('idx_failurereason_project_id', 'failurereason', ['project_id'], unique=False)

Example 31

View license
def upgrade():
    op.add_column('build', sa.Column('collection_id', sa.GUID(), nullable=True))
    op.create_index('idx_build_collection_id', 'build', ['collection_id'])

Example 32

View license
def upgrade():
    op.drop_column('filecoverage', 'project_id')
    op.add_column('filecoverage', sa.Column('project_id', sa.GUID(), nullable=False))

Example 33

Project: changes
Source File: 26dbd6ff063c_add_task.py
View license
def upgrade():
    op.create_table(
        'task',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('task_name', sa.String(length=128), nullable=False),
        sa.Column('parent_id', sa.GUID(), nullable=False),
        sa.Column('child_id', sa.GUID(), nullable=False),
        sa.Column('status', sa.Enum(), nullable=False),
        sa.Column('result', sa.Enum(), nullable=False),
        sa.Column('num_retries', sa.Integer(), nullable=False),
        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('date_modified', sa.DateTime(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('task_name', 'parent_id', 'child_id', name='unq_task_entity')
    )

    op.create_index('idx_task_parent_id', 'task', ['parent_id', 'task_name'])
    op.create_index('idx_task_child_id', 'task', ['child_id', 'task_name'])

Example 34

View license
def upgrade():
    from changes.constants import Result

    connection = op.get_bind()

    testgroups_table = table(
        'testgroup',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('build_id', sa.GUID(), nullable=False),
        sa.Column('project_id', sa.GUID(), nullable=False),
        sa.Column('parent_id', sa.GUID(), nullable=True),
        sa.Column('name_sha', sa.String(length=40), nullable=False),
        sa.Column('duration', sa.Integer(), nullable=True),
        sa.Column('num_tests', sa.Integer(), nullable=True),
        sa.Column('num_failed', sa.Integer(), nullable=True),
        sa.Column('result', sa.Enum(), nullable=True),
        sa.Column('name', sa.Text(), nullable=True),
        sa.Column('date_created', sa.DateTime(), nullable=True),
    )
    testgroups_m2m_table = table(
        'testgroup_test',
        sa.Column('group_id', sa.GUID(), nullable=False),
        sa.Column('test_id', sa.GUID(), nullable=False),
    )
    testcases_table = table(
        'test',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('build_id', sa.GUID(), nullable=False),
        sa.Column('project_id', sa.GUID(), nullable=False),
        sa.Column('package', sa.Text(), nullable=True),
        sa.Column('name', sa.Text(), nullable=True),
        sa.Column('label_sha', sa.String(length=40), nullable=False),
        sa.Column('duration', sa.Integer(), nullable=True),
        sa.Column('result', sa.Enum(), nullable=True),
        sa.Column('date_created', sa.DateTime(), nullable=True),
    )

    for testcase in connection.execute(testcases_table.select()):
        print("Migrating TestCase %s" % (testcase.id,))

        if testcase.package:
            full_name = testcase.package + '.' + testcase.name
        else:
            full_name = testcase.name
        group_id = uuid4()

        # find the parent
        result = connection.execute(testgroups_table.select().where(sa.and_(
            testgroups_table.c.build_id == testcase.build_id,
            testgroups_table.c.name == (testcase.package or testcase.name.rsplit('.', 1)[0]),
        )).limit(1)).fetchone()

        connection.execute(
            testgroups_table.insert().values(
                id=group_id,
                build_id=testcase.build_id,
                project_id=testcase.project_id,
                name=full_name,
                name_sha=testcase.label_sha,
                date_created=testcase.date_created,
                duration=testcase.duration,
                parent_id=result.id,
                result=Result(testcase.result),
                num_tests=1,
                num_failed=1 if testcase.result == Result.failed else 0,
            )
        )

        connection.execute(
            testgroups_m2m_table.insert().values(
                group_id=group_id,
                test_id=testcase.id,
            )
        )

Example 35

View license
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('repository',
    sa.Column('id', sa.GUID(), nullable=False),
    sa.Column('url', sa.String(length=200), nullable=False),
    sa.Column('date_created', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('url')
    )
    op.create_table('node',
    sa.Column('id', sa.GUID(), nullable=False),
    sa.Column('label', sa.String(length=128), nullable=True),
    sa.Column('date_created', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('author',
    sa.Column('id', sa.GUID(), nullable=False),
    sa.Column('name', sa.String(length=128), nullable=False),
    sa.Column('email', sa.String(length=128), nullable=True),
    sa.Column('date_created', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email'),
    sa.UniqueConstraint('name')
    )
    op.create_table('remoteentity',
    sa.Column('id', sa.GUID(), nullable=False),
    sa.Column('type', sa.String(), nullable=False),
    sa.Column('provider', sa.String(length=128), nullable=False),
    sa.Column('remote_id', sa.String(length=128), nullable=False),
    sa.Column('internal_id', sa.GUID(), nullable=False),
    sa.Column('data', sa.JSONEncodedDict(), nullable=True),
    sa.Column('date_created', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('provider','remote_id','type', name='remote_identifier')
    )
    op.create_table('project',
    sa.Column('id', sa.GUID(), nullable=False),
    sa.Column('slug', sa.String(length=64), nullable=False),
    sa.Column('repository_id', sa.GUID(), nullable=False),
    sa.Column('name', sa.String(length=64), nullable=True),
    sa.Column('date_created', sa.DateTime(), nullable=True),
    sa.Column('avg_build_time', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('slug')
    )
    op.create_table('revision',
    sa.Column('repository_id', sa.GUID(), nullable=False),
    sa.Column('sha', sa.String(length=40), nullable=False),
    sa.Column('author_id', sa.GUID(), nullable=True),
    sa.Column('message', sa.Text(), nullable=True),
    sa.Column('parents', postgresql.ARRAY(sa.String(length=40)), nullable=True),
    sa.Column('date_created', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['author.id'], ),
    sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], ),
    sa.PrimaryKeyConstraint('repository_id', 'sha')
    )
    op.create_table('change',
    sa.Column('id', sa.GUID(), nullable=False),
    sa.Column('hash', sa.String(length=40), nullable=False),
    sa.Column('repository_id', sa.GUID(), nullable=False),
    sa.Column('project_id', sa.GUID(), nullable=False),
    sa.Column('author_id', sa.GUID(), nullable=True),
    sa.Column('label', sa.String(length=128), nullable=False),
    sa.Column('message', sa.Text(), nullable=True),
    sa.Column('date_created', sa.DateTime(), nullable=True),
    sa.Column('date_modified', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['author.id'], ),
    sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
    sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('hash')
    )
    op.create_table('patch',
    sa.Column('id', sa.GUID(), nullable=False),
    sa.Column('change_id', sa.GUID(), nullable=True),
    sa.Column('repository_id', sa.GUID(), nullable=False),
    sa.Column('project_id', sa.GUID(), nullable=False),
    sa.Column('parent_revision_sha', sa.String(length=40), nullable=False),
    sa.Column('label', sa.String(length=64), nullable=False),
    sa.Column('url', sa.String(length=200), nullable=True),
    sa.Column('diff', sa.Text(), nullable=True),
    sa.Column('message', sa.Text(), nullable=True),
    sa.Column('date_created', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['change_id'], ['change.id'], ),
    sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
    sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('build',
    sa.Column('id', sa.GUID(), nullable=False),
    sa.Column('change_id', sa.GUID(), nullable=True),
    sa.Column('repository_id', sa.GUID(), nullable=False),
    sa.Column('project_id', sa.GUID(), nullable=False),
    sa.Column('parent_revision_sha', sa.String(length=40), nullable=True),
    sa.Column('patch_id', sa.GUID(), nullable=True),
    sa.Column('author_id', sa.GUID(), nullable=True),
    sa.Column('label', sa.String(length=128), nullable=False),
    sa.Column('status', sa.Enum(), nullable=False),
    sa.Column('result', sa.Enum(), nullable=False),
    sa.Column('message', sa.Text(), nullable=True),
    sa.Column('duration', sa.Integer(), 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('date_modified', sa.DateTime(), nullable=True),
    sa.Column('data', sa.JSONEncodedDict(), nullable=True),
    sa.ForeignKeyConstraint(['author_id'], ['author.id'], ),
    sa.ForeignKeyConstraint(['change_id'], ['change.id'], ),
    sa.ForeignKeyConstraint(['patch_id'], ['patch.id'], ),
    sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
    sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('filecoverage',
    sa.Column('id', sa.GUID(), nullable=False),
    sa.Column('build_id', sa.GUID(), nullable=False),
    sa.Column('filename', sa.String(length=256), nullable=False),
    sa.Column('project_id', sa.Integer(), nullable=False),
    sa.Column('data', sa.Text(), nullable=True),
    sa.Column('date_created', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['build_id'], ['build.id'], ),
    sa.PrimaryKeyConstraint('id', 'filename')
    )
    op.create_table('test',
    sa.Column('id', sa.GUID(), nullable=False),
    sa.Column('build_id', sa.GUID(), nullable=False),
    sa.Column('project_id', sa.GUID(), nullable=False),
    sa.Column('group_sha', sa.String(length=40), nullable=False),
    sa.Column('label_sha', sa.String(length=40), nullable=False),
    sa.Column('group', sa.Text(), nullable=False),
    sa.Column('name', sa.Text(), nullable=False),
    sa.Column('package', sa.Text(), nullable=True),
    sa.Column('result', sa.Enum(), nullable=True),
    sa.Column('duration', sa.Integer(), nullable=True),
    sa.Column('message', sa.Text(), nullable=True),
    sa.Column('date_created', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['build_id'], ['build.id'], ),
    sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('build_id','group_sha','label_sha', name='_test_key')
    )
    op.create_table('phase',
    sa.Column('id', sa.GUID(), nullable=False),
    sa.Column('build_id', sa.GUID(), nullable=False),
    sa.Column('repository_id', sa.GUID(), nullable=False),
    sa.Column('project_id', sa.GUID(), nullable=False),
    sa.Column('label', sa.String(length=128), nullable=False),
    sa.Column('status', sa.Enum(), nullable=False),
    sa.Column('result', sa.Enum(), nullable=False),
    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.ForeignKeyConstraint(['build_id'], ['build.id'], ),
    sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
    sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('step',
    sa.Column('id', sa.GUID(), nullable=False),
    sa.Column('build_id', sa.GUID(), nullable=False),
    sa.Column('phase_id', sa.GUID(), nullable=False),
    sa.Column('repository_id', sa.GUID(), nullable=False),
    sa.Column('project_id', sa.GUID(), nullable=False),
    sa.Column('label', sa.String(length=128), nullable=False),
    sa.Column('status', sa.Enum(), nullable=False),
    sa.Column('result', sa.Enum(), nullable=False),
    sa.Column('node_id', sa.GUID(), 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.ForeignKeyConstraint(['build_id'], ['build.id'], ),
    sa.ForeignKeyConstraint(['node_id'], ['node.id'], ),
    sa.ForeignKeyConstraint(['phase_id'], ['phase.id'], ),
    sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
    sa.ForeignKeyConstraint(['repository_id'], ['repository.id'], ),
    sa.PrimaryKeyConstraint('id')
    )

Example 36

View license
def upgrade():
    connection = op.get_bind()

    logsources_table = table(
        'logsource',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('build_id', sa.GUID(), nullable=False),
        sa.Column('name', sa.String(64), nullable=True),
    )
    logchunks_table = table(
        'logchunk',
        sa.Column('source_id', sa.GUID(), nullable=False),
    )

    done = set()

    for logsource in connection.execute(logsources_table.select()):
        # migrate group to suite
        key = (logsource.build_id, logsource.name)
        if key in done:
            continue

        print("Checking LogSource %s - %s" % (
            logsource.build_id, logsource.name))
        query = logchunks_table.delete().where(
            logchunks_table.c.source_id.in_(select([logchunks_table]).where(
                sa.and_(
                    logsources_table.c.build_id == logsource.build_id,
                    logsources_table.c.name == logsource.name,
                    logsources_table.c.id != logsource.id,
                ),
            ))
        )
        connection.execute(query)

        query = logsources_table.delete().where(
            sa.and_(
                logsources_table.c.build_id == logsource.build_id,
                logsources_table.c.name == logsource.name,
                logsources_table.c.id != logsource.id,
            )
        )

        connection.execute(query)

        done.add(key)

    op.create_unique_constraint(
        'unq_logsource_key', 'logsource', ['build_id', 'name'])
    op.drop_index('idx_logsource_build_id', 'logsource')

Example 37

View license
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('build', sa.Column('parent_id', sa.GUID(), nullable=True))
    op.drop_column('build', u'parent')

Example 38

View license
def upgrade():
    op.add_column('test', sa.Column('step_id', sa.GUID(), nullable=True))
    op.create_foreign_key('test_step_id_fkey', 'test', 'jobstep', ['step_id'], ['id'], ondelete='CASCADE')
    op.create_index('idx_test_step_id', 'test', ['step_id'])

Example 39

View license
def upgrade():
    op.add_column('jobplan', sa.Column('snapshot_image_id', sa.GUID(),
        sa.ForeignKey('snapshot_image.id', ondelete="RESTRICT"), nullable=True))

Example 40

View license
def upgrade():
    op.create_table(
        'logsource',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('build_id', sa.GUID(), nullable=False),
        sa.Column('project_id', sa.GUID(), nullable=False),
        sa.Column('name', sa.String(length=64), nullable=False),
        sa.Column('date_created', sa.DateTime(), nullable=True),
        sa.ForeignKeyConstraint(['build_id'], ['build.id'], ),
        sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
        sa.PrimaryKeyConstraint('id')
    )

    op.create_index('idx_logsource_project_id', 'logsource', ['project_id'])
    op.create_index('idx_logsource_build_id', 'logsource', ['build_id'])

    op.create_table(
        'logchunk',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('build_id', sa.GUID(), nullable=False),
        sa.Column('project_id', sa.GUID(), nullable=False),
        sa.Column('source_id', sa.GUID(), nullable=False),
        sa.Column('offset', sa.Integer(), nullable=False),
        sa.Column('size', sa.Integer(), nullable=False),
        sa.Column('text', sa.Text(), nullable=False),
        sa.Column('date_created', sa.DateTime(), nullable=True),
        sa.ForeignKeyConstraint(['build_id'], ['build.id'], ),
        sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
        sa.ForeignKeyConstraint(['source_id'], ['logsource.id'], ),
        sa.PrimaryKeyConstraint('id')
    )

    op.create_index('idx_logchunk_project_id', 'logchunk', ['project_id'])
    op.create_index('idx_logchunk_build_id', 'logchunk', ['build_id'])
    op.create_index('idx_logchunk_source_id', 'logchunk', ['source_id'])

Example 41

View license
def upgrade():
    op.add_column('plan', sa.Column('snapshot_plan_id', sa.GUID(), nullable=True))
    op.create_foreign_key('plan_snapshot_plan_id_fkey', 'plan', 'plan', ['snapshot_plan_id'], ['id'], ondelete='SET NULL')

Example 42

View license
def upgrade():
    op.add_column('filecoverage', sa.Column('step_id', sa.GUID(), nullable=True))

Example 43

View license
def upgrade():
    op.add_column('jobstep', sa.Column('replacement_id', sa.GUID(),
                                       sa.ForeignKey('jobstep.id', ondelete="CASCADE"),
                                       unique=True, nullable=True))

Example 44

View license
def upgrade():
    from changes.constants import Result

    connection = op.get_bind()

    testgroups_table = table(
        'testgroup',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('result', sa.Enum(), nullable=True),
    )
    testgroups_m2m_table = table(
        'testgroup_test',
        sa.Column('group_id', sa.GUID(), nullable=False),
        sa.Column('test_id', sa.GUID(), nullable=False),
    )
    testcases_table = table(
        'test',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('result', sa.Enum(), nullable=True),
    )

    # perform data migrations
    for testgroup in connection.execute(testgroups_table.select()):
        # migrate group to suite
        print("Migrating TestGroup %s" % (testgroup.id,))

        query = select([testcases_table]).where(
            sa.and_(
                testgroups_m2m_table.c.test_id == testcases_table.c.id,
                testgroups_m2m_table.c.group_id == testgroup.id,
            )
        )

        result = Result.unknown
        for testcase in connection.execute(query):
            result = max(result, Result(testcase.result))

        connection.execute(
            testgroups_table.update().where(
                testgroups_table.c.id == testgroup.id,
            ).values({
                testgroups_table.c.result: result,
            })
        )

Example 45

View license
def upgrade():
    op.add_column('plan', sa.Column('project_id', sa.GUID(), nullable=True))
    op.create_foreign_key('plan_project_id_fkey', 'plan', 'project', ['project_id'], ['id'], ondelete='CASCADE')

Example 46

View license
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        'buildphase',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('build_id', sa.GUID(), nullable=False),
        sa.Column('project_id', sa.GUID(), nullable=False),
        sa.Column('label', sa.String(length=128), nullable=False),
        sa.Column('status', sa.Enum(), server_default='0', nullable=False),
        sa.Column('result', sa.Enum(), server_default='0', nullable=False),
        sa.Column('order', sa.Integer(), server_default='0', nullable=False),
        sa.Column('duration', sa.Integer(), nullable=True),
        sa.Column('date_started', sa.DateTime(), nullable=True),
        sa.Column('date_finished', sa.DateTime(), nullable=True),
        sa.Column('date_created', sa.DateTime(), server_default='now()', nullable=False),
        sa.ForeignKeyConstraint(['build_id'], ['build.id'], ondelete='CASCADE'),
        sa.ForeignKeyConstraint(['project_id'], ['project.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('build_id', 'label', name='unq_buildphase_key')
    )

Example 47

View license
def upgrade():
    op.create_table(
        'revisionresult',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('build_id', sa.GUID(), nullable=True),
        sa.Column('revision_sha', sa.String(
            length=40), nullable=False),
        sa.Column('project_id', sa.GUID(), nullable=False),
        sa.Column('result', sa.Enum(), nullable=False),
        sa.ForeignKeyConstraint(['build_id'], ['build.id'], ),
        sa.ForeignKeyConstraint(
            ['project_id'], ['project.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('project_id', 'revision_sha',
                            name='unq_project_revision_pair')
    )
    op.add_column('bazeltarget', sa.Column('result_source',
                                           sa.Enum()))
    op.alter_column('bazeltarget', 'step_id',
                    existing_type=postgresql.UUID(),
                    nullable=True)
    # don't do selective testing by default
    op.add_column('build', sa.Column('selective_testing_policy',
                                     sa.Enum()))

Example 48

View license
def upgrade():
    op.add_column('snapshot', sa.Column('source_id', sa.GUID(), nullable=True))

Example 49

View license
def upgrade():
    connection = op.get_bind()

    plan_table = table(
        'plan',
        sa.Column('id', sa.GUID(), nullable=False),
        sa.Column('project_id', sa.GUID(), nullable=False),
    )

    project_plan_table = table(
        'project_plan',
        sa.Column('plan_id', sa.GUID(), nullable=False),
        sa.Column('project_id', sa.GUID(), nullable=False),
    )

    for project_plan in connection.execute(project_plan_table.select()):
        print("Migrating ProjectPlan plan_id=%s project_id=%s" % (
            project_plan.plan_id, project_plan.project_id))

        connection.execute(
            plan_table.update().where(
                plan_table.c.id == project_plan.plan_id,
            ).values({
                plan_table.c.project_id: project_plan.project_id,
            })
        )

Example 50

View license
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('revision', sa.Column('committer_id', sa.GUID(), nullable=True))
    op.add_column('revision', sa.Column('date_committed', sa.DateTime(), nullable=True))