コード例 #1
0
def define_workers_table(meta):
    workers = Table('workers',
                    meta,
                    Column('id', String(36), primary_key=True, nullable=False),
                    Column('host', String(255), nullable=False),
                    Column('process_id', Integer(), nullable=True),
                    Column('created_at', DateTime(), nullable=False),
                    Column('updated_at', DateTime(), nullable=False),
                    mysql_engine='InnoDB',
                    mysql_charset='utf8',
                    extend_existing=True)
    return workers
コード例 #2
0
ファイル: 004_add_jobs_table.py プロジェクト: cp16net/qonos
def define_jobs_table(meta):
    jobs = Table('jobs',
                 meta,
                 Column('id', String(36), primary_key=True, nullable=False),
                 Column('schedule_id', String(36)),
                 Column('tenant', String(255), nullable=False),
                 Column('worker_id', String(36), nullable=True),
                 Column('status', String(255), nullable=True),
                 Column('action', String(255), nullable=False),
                 Column('retry_count', Integer(), nullable=False, default=0),
                 Column('timeout', DateTime(), nullable=False),
                 Column('hard_timeout', DateTime(), nullable=False),
                 Column('created_at', DateTime(), nullable=False),
                 Column('updated_at', DateTime(), nullable=False),
                 mysql_engine='InnoDB',
                 mysql_charset='utf8',
                 extend_existing=True)

    return jobs
コード例 #3
0
def define_job_faults_table(meta):
    job_faults = Table('job_faults',
                       meta,
                       Column('id',
                              String(36),
                              primary_key=True,
                              nullable=False),
                       Column('job_id', String(36), nullable=False),
                       Column('schedule_id', String(36), nullable=False),
                       Column('tenant', String(255), nullable=False),
                       Column('worker_id', String(36), nullable=False),
                       Column('action', String(255), nullable=False),
                       Column('message', String(255), nullable=True),
                       Column('job_metadata', Text(), nullable=True),
                       Column('created_at', DateTime(), nullable=False),
                       Column('updated_at', DateTime(), nullable=False),
                       mysql_engine='InnoDB',
                       mysql_charset='utf8',
                       extend_existing=True)

    return job_faults
コード例 #4
0
def define_schedules_table(meta):
    schedules = Table('schedules',
                      meta,
                      Column('id',
                             String(36),
                             primary_key=True,
                             nullable=False),
                      Column('tenant', String(255), nullable=False),
                      Column('action', String(255), nullable=False),
                      Column('minute', Integer(), nullable=True),
                      Column('hour', Integer(), nullable=True),
                      Column('day_of_month', Integer(), nullable=True),
                      Column('month', Integer(), nullable=True),
                      Column('day_of_week', Integer(), nullable=True),
                      Column('last_scheduled', DateTime(), nullable=True),
                      Column('next_run', DateTime(), nullable=True),
                      Column('created_at', DateTime(), nullable=False),
                      Column('updated_at', DateTime(), nullable=False),
                      mysql_engine='InnoDB',
                      mysql_charset='utf8',
                      extend_existing=True)
    return schedules
コード例 #5
0
def define_job_metadata_table(meta):
    (define_jobs_table,) = from_migration_import(
        '004_add_jobs_table',
        ['define_jobs_table'])

    jobs = define_jobs_table(meta)

    # NOTE(dperaza) DB2: specify the UniqueConstraint option when creating
    # the table will cause an index being created to specify the index
    # name and skip the step of creating another index with the same columns.
    # The index name is needed so it can be dropped and re-created later on.

    constr_kwargs = {}
    if meta.bind.name == 'ibm_db_sa':
        constr_kwargs['name'] = 'ix_job_metadata_job_id_key'

    job_metadata = Table('job_metadata',
                         meta,
                         Column('id',
                                String(36),
                                primary_key=True,
                                nullable=False),
                         Column('job_id',
                                String(36),
                                ForeignKey(jobs.c.id),
                                nullable=False),
                         Column('key', String(255), nullable=False),
                         Column('value', Text(), nullable=False),
                         Column('created_at', DateTime(), nullable=False),
                         Column('updated_at', DateTime(), nullable=False),
                         UniqueConstraint('job_id', 'key',
                                          **constr_kwargs),
                         mysql_engine='InnoDB',
                         mysql_charset='utf8',
                         extend_existing=True)

    return job_metadata