def upgrade():
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        op.add_column('change', sa.Column('outdated', sa.Boolean()))

    connection = op.get_bind()
    change = sa.sql.table('change', sa.sql.column('outdated', sa.Boolean()))
    connection.execute(change.update().values({'outdated': False}))

    sqlite_alter_columns('change', [
        sa.Column('outdated', sa.Boolean(), index=True, nullable=False),
    ])
def upgrade():
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        op.add_column('revision', sa.Column('can_submit', sa.Boolean()))

    conn = op.get_bind()
    q = sa.text('update revision set can_submit=:submit')
    conn.execute(q, submit=False)

    sqlite_alter_columns('revision', [
        sa.Column('can_submit', sa.Boolean(), nullable=False),
        ])
def upgrade():
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        op.add_column('revision', sa.Column('can_submit', sa.Boolean()))

    conn = op.get_bind()
    q = sa.text('update revision set can_submit=:submit')
    conn.execute(q, submit=False)

    sqlite_alter_columns('revision', [
        sa.Column('can_submit', sa.Boolean(), nullable=False),
    ])
def upgrade():
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        op.add_column('change', sa.Column('outdated', sa.Boolean()))

    connection = op.get_bind()
    change = sa.sql.table('change',
                          sa.sql.column('outdated', sa.Boolean()))
    connection.execute(change.update().values({'outdated':False}))

    sqlite_alter_columns('change', [
        sa.Column('outdated', sa.Boolean(), index=True, nullable=False),
        ])
def upgrade():
    sqlite_drop_columns('message', ['name'])
    sqlite_drop_columns('comment', ['name'])
    sqlite_drop_columns('approval', ['name'])
    sqlite_drop_columns('change', ['owner'])

    op.create_table(
        'account', sa.Column('key', sa.Integer(), nullable=False),
        sa.Column('id', sa.Integer(), index=True, unique=True, nullable=False),
        sa.Column('name', sa.String(length=255)),
        sa.Column('username', sa.String(length=255)),
        sa.Column('email', sa.String(length=255)),
        sa.PrimaryKeyConstraint('key'))

    op.create_index(op.f('ix_account_name'), 'account', ['name'], unique=True)
    op.create_index(op.f('ix_account_username'),
                    'account', ['name'],
                    unique=True)
    op.create_index(op.f('ix_account_email'), 'account', ['name'], unique=True)

    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        op.add_column('message', sa.Column('account_key', sa.Integer()))
        op.add_column('comment', sa.Column('account_key', sa.Integer()))
        op.add_column('approval', sa.Column('account_key', sa.Integer()))
        op.add_column('change', sa.Column('account_key', sa.Integer()))
    sqlite_alter_columns(
        'message',
        [sa.Column('account_key', sa.Integer(), sa.ForeignKey('account.key'))])
    sqlite_alter_columns(
        'comment',
        [sa.Column('account_key', sa.Integer(), sa.ForeignKey('account.key'))])
    sqlite_alter_columns(
        'approval',
        [sa.Column('account_key', sa.Integer(), sa.ForeignKey('account.key'))])
    sqlite_alter_columns(
        'change',
        [sa.Column('account_key', sa.Integer(), sa.ForeignKey('account.key'))])

    op.create_index(op.f('ix_message_account_key'),
                    'message', ['account_key'],
                    unique=False)
    op.create_index(op.f('ix_comment_account_key'),
                    'comment', ['account_key'],
                    unique=False)
    op.create_index(op.f('ix_approval_account_key'),
                    'approval', ['account_key'],
                    unique=False)
    op.create_index(op.f('ix_change_account_key'),
                    'change', ['account_key'],
                    unique=False)

    connection = op.get_bind()
    project = sa.sql.table('project', sa.sql.column('updated', sa.DateTime))
    connection.execute(project.update().values({'updated': None}))

    approval = sa.sql.table('approval', sa.sql.column('pending'))
    connection.execute(approval.delete().where(approval.c.pending == False))
예제 #6
0
def upgrade():
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        op.add_column('comment', sa.Column('file_key', sa.Integer()))
    sqlite_alter_columns(
        'comment',
        [sa.Column('file_key', sa.Integer(), sa.ForeignKey('file.key'))])

    update_query = sa.text(
        'update comment set file_key=:file_key where key=:key')
    file_query = sa.text(
        'select f.key from file f where f.revision_key=:revision_key and f.path=:path'
    )

    file_insert_query = sa.text(
        'insert into file (key, revision_key, path, old_path, status, inserted, deleted) '
        ' values (NULL, :revision_key, :path, NULL, NULL, NULL, NULL)')

    conn = op.get_bind()

    countres = conn.execute('select count(*) from comment')
    comments = countres.fetchone()[0]

    comment_res = conn.execute(
        'select p.name, c.number, c.status, r.key, r.number, m.file, m.key '
        'from project p, change c, revision r, comment m '
        'where m.revision_key=r.key and r.change_key=c.key and '
        'c.project_key=p.key order by p.name')

    count = 0
    for (pname, cnumber, cstatus, rkey, rnumber, mfile,
         mkey) in comment_res.fetchall():
        count += 1
        sys.stdout.write('Comment %s / %s\r' % (count, comments))
        sys.stdout.flush()

        file_res = conn.execute(file_query, revision_key=rkey, path=mfile)
        file_key = file_res.fetchone()
        if not file_key:
            conn.execute(file_insert_query, revision_key=rkey, path=mfile)
            file_res = conn.execute(file_query, revision_key=rkey, path=mfile)
            file_key = file_res.fetchone()
        fkey = file_key[0]
        file_res = conn.execute(update_query, file_key=fkey, key=mkey)
    sqlite_drop_columns('comment', ['revision_key', 'file'])
    print
def upgrade():
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        op.add_column('revision', sa.Column('fetch_auth', sa.Boolean()))
        op.add_column('revision', sa.Column('fetch_ref', sa.String(length=255)))

    conn = op.get_bind()
    res = conn.execute('select r.key, r.number, c.number from revision r, "change" c where r.change_key=c.key')
    for (rkey, rnumber, cnumber) in res.fetchall():
        q = sa.text('update revision set fetch_auth=:auth, fetch_ref=:ref where "key"=:key')
        ref = 'refs/changes/%s/%s/%s' % (str(cnumber)[-2:], cnumber, rnumber)
        res = conn.execute(q, key=rkey, ref=ref, auth=False)

    sqlite_alter_columns('revision', [
        sa.Column('fetch_auth', sa.Boolean(), nullable=False),
        sa.Column('fetch_ref', sa.String(length=255), nullable=False)
        ])
예제 #8
0
def upgrade():
    op.create_table('branch',
    sa.Column('key', sa.Integer(), nullable=False),
    sa.Column('project_key', sa.Integer(), sa.ForeignKey('project.key'), index=True, nullable=False),
    sa.Column('name', sa.String(length=255), nullable=False),
    sa.PrimaryKeyConstraint('key')
    )
    op.create_table('pending_cherry_pick',
    sa.Column('key', sa.Integer(), nullable=False),
    sa.Column('revision_key', sa.Integer(), sa.ForeignKey('revision.key'), index=True, nullable=False),
    sa.Column('branch', sa.String(length=255), nullable=False),
    sa.Column('message', sa.Text(), nullable=False),
    sa.PrimaryKeyConstraint('key')
    )

    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        op.add_column('change', sa.Column('pending_rebase', sa.Boolean()))
        op.add_column('change', sa.Column('pending_topic', sa.Boolean()))
        op.add_column('change', sa.Column('pending_status', sa.Boolean()))
        op.add_column('change', sa.Column('pending_status_message', sa.Text()))
        op.add_column('revision', sa.Column('pending_message', sa.Boolean()))

    connection = op.get_bind()
    change = sa.sql.table('change',
                          sa.sql.column('pending_rebase', sa.Boolean()),
                          sa.sql.column('pending_topic', sa.Boolean()),
                          sa.sql.column('pending_status', sa.Boolean()))
    connection.execute(change.update().values({'pending_rebase':False,
                                               'pending_topic':False,
                                               'pending_status':False}))
    revision = sa.sql.table('revision',
                            sa.sql.column('pending_message', sa.Boolean()))
    connection.execute(revision.update().values({'pending_message':False}))

    sqlite_alter_columns('change', [
        sa.Column('pending_rebase', sa.Boolean(), index=True, nullable=False),
        sa.Column('pending_topic', sa.Boolean(), index=True, nullable=False),
        sa.Column('pending_status', sa.Boolean(), index=True, nullable=False),
        ])
    sqlite_alter_columns('revision', [
        sa.Column('pending_message', sa.Boolean(), index=True, nullable=False),
        ])
예제 #9
0
def upgrade():
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        op.add_column('message', sa.Column('draft', sa.Boolean()))
        op.add_column('comment', sa.Column('draft', sa.Boolean()))
        op.add_column('approval', sa.Column('draft', sa.Boolean()))

    conn = op.get_bind()
    conn.execute("update message set draft=pending")
    conn.execute("update comment set draft=pending")
    conn.execute("update approval set draft=pending")

    sqlite_alter_columns('message', [
        sa.Column('draft', sa.Boolean(), index=True, nullable=False),
        ])

    sqlite_alter_columns('comment', [
        sa.Column('draft', sa.Boolean(), index=True, nullable=False),
        ])

    sqlite_alter_columns('approval', [
        sa.Column('draft', sa.Boolean(), index=True, nullable=False),
        ])

    sqlite_drop_columns('comment', ['pending'])
    sqlite_drop_columns('approval', ['pending'])
def upgrade():
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        op.add_column('comment', sa.Column('file_key', sa.Integer()))
    sqlite_alter_columns('comment', [
            sa.Column('file_key', sa.Integer(), sa.ForeignKey('file.key'))
            ])

    update_query = sa.text('update comment set file_key=:file_key where key=:key')
    file_query = sa.text('select f.key from file f where f.revision_key=:revision_key and f.path=:path')

    file_insert_query = sa.text('insert into file (key, revision_key, path, old_path, status, inserted, deleted) '
                                ' values (NULL, :revision_key, :path, NULL, NULL, NULL, NULL)')

    conn = op.get_bind()

    countres = conn.execute('select count(*) from comment')
    comments = countres.fetchone()[0]

    comment_res = conn.execute('select p.name, c.number, c.status, r.key, r.number, m.file, m.key '
                               'from project p, change c, revision r, comment m '
                               'where m.revision_key=r.key and r.change_key=c.key and '
                               'c.project_key=p.key order by p.name')

    count = 0
    for (pname, cnumber, cstatus, rkey, rnumber, mfile, mkey) in comment_res.fetchall():
        count += 1
        sys.stdout.write('Comment %s / %s\r' % (count, comments))
        sys.stdout.flush()

        file_res = conn.execute(file_query, revision_key=rkey, path=mfile)
        file_key = file_res.fetchone()
        if not file_key:
            conn.execute(file_insert_query, revision_key=rkey, path=mfile)
            file_res = conn.execute(file_query, revision_key=rkey, path=mfile)
            file_key = file_res.fetchone()
        fkey = file_key[0]
        file_res = conn.execute(update_query, file_key=fkey, key=mkey)
    sqlite_drop_columns('comment', ['revision_key', 'file'])
    print
def upgrade():
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        op.add_column('revision', sa.Column('fetch_auth', sa.Boolean()))
        op.add_column('revision', sa.Column('fetch_ref',
                                            sa.String(length=255)))

    conn = op.get_bind()
    res = conn.execute(
        'select r.key, r.number, c.number from revision r, "change" c where r.change_key=c.key'
    )
    for (rkey, rnumber, cnumber) in res.fetchall():
        q = sa.text(
            'update revision set fetch_auth=:auth, fetch_ref=:ref where "key"=:key'
        )
        ref = 'refs/changes/%s/%s/%s' % (str(cnumber)[-2:], cnumber, rnumber)
        res = conn.execute(q, key=rkey, ref=ref, auth=False)

    sqlite_alter_columns('revision', [
        sa.Column('fetch_auth', sa.Boolean(), nullable=False),
        sa.Column('fetch_ref', sa.String(length=255), nullable=False)
    ])
예제 #12
0
def upgrade():
    sqlite_drop_columns("message", ["name"])
    sqlite_drop_columns("comment", ["name"])
    sqlite_drop_columns("approval", ["name"])
    sqlite_drop_columns("change", ["owner"])

    op.create_table(
        "account",
        sa.Column("key", sa.Integer(), nullable=False),
        sa.Column("id", sa.Integer(), index=True, unique=True, nullable=False),
        sa.Column("name", sa.String(length=255)),
        sa.Column("username", sa.String(length=255)),
        sa.Column("email", sa.String(length=255)),
        sa.PrimaryKeyConstraint("key"),
    )

    op.create_index(op.f("ix_account_name"), "account", ["name"], unique=True)
    op.create_index(op.f("ix_account_username"), "account", ["name"], unique=True)
    op.create_index(op.f("ix_account_email"), "account", ["name"], unique=True)

    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        op.add_column("message", sa.Column("account_key", sa.Integer()))
        op.add_column("comment", sa.Column("account_key", sa.Integer()))
        op.add_column("approval", sa.Column("account_key", sa.Integer()))
        op.add_column("change", sa.Column("account_key", sa.Integer()))
    sqlite_alter_columns("message", [sa.Column("account_key", sa.Integer(), sa.ForeignKey("account.key"))])
    sqlite_alter_columns("comment", [sa.Column("account_key", sa.Integer(), sa.ForeignKey("account.key"))])
    sqlite_alter_columns("approval", [sa.Column("account_key", sa.Integer(), sa.ForeignKey("account.key"))])
    sqlite_alter_columns("change", [sa.Column("account_key", sa.Integer(), sa.ForeignKey("account.key"))])

    op.create_index(op.f("ix_message_account_key"), "message", ["account_key"], unique=False)
    op.create_index(op.f("ix_comment_account_key"), "comment", ["account_key"], unique=False)
    op.create_index(op.f("ix_approval_account_key"), "approval", ["account_key"], unique=False)
    op.create_index(op.f("ix_change_account_key"), "change", ["account_key"], unique=False)

    connection = op.get_bind()
    project = sa.sql.table("project", sa.sql.column("updated", sa.DateTime))
    connection.execute(project.update().values({"updated": None}))

    approval = sa.sql.table("approval", sa.sql.column("pending"))
    connection.execute(approval.delete().where(approval.c.pending == False))
def downgrade():
    sqlite_alter_columns(
        'change',
        [sa.Column('status', sa.String(8), index=True, nullable=False)])
def downgrade():
    sqlite_alter_columns('change', [
        sa.Column('status', sa.String(8), index=True, nullable=False)
        ])