Merge "Quote identifiers in migrations"

This commit is contained in:
Jenkins 2014-09-08 14:56:58 +00:00 committed by Gerrit Code Review
commit ad65967d15
4 changed files with 15 additions and 15 deletions

View File

@ -15,9 +15,9 @@ import sqlalchemy as sa
def upgrade():
op.drop_index('ix_account_name')
op.drop_index('ix_account_username')
op.drop_index('ix_account_email')
op.drop_index('ix_account_name', 'account')
op.drop_index('ix_account_username', 'account')
op.drop_index('ix_account_email', 'account')
op.create_index(op.f('ix_account_name'), 'account', ['name'])
op.create_index(op.f('ix_account_username'), 'account', ['username'])
op.create_index(op.f('ix_account_email'), 'account', ['email'])

View File

@ -18,12 +18,12 @@ def upgrade():
op.add_column('project', sa.Column('updated', sa.DateTime))
conn = op.get_bind()
res = conn.execute("select key, name from project")
res = conn.execute('select "key", name from project')
for (key, name) in res.fetchall():
q = sa.text("select max(updated) from change where project_key=:key")
res = conn.execute(q, key=key)
for (updated,) in res.fetchall():
q = sa.text("update project set updated=:updated where key=:key")
q = sa.text('update project set updated=:updated where "key"=:key')
conn.execute(q, key=key, updated=updated)
op.create_index(op.f('ix_project_updated'), 'project', ['updated'], unique=False)

View File

@ -17,7 +17,7 @@ import sqlalchemy as sa
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('project',
sa.Column('key', sa.Integer(), nullable=False),
sa.Column('key', sa.Integer(), nullable=False, quote=True),
sa.Column('name', sa.String(length=255), nullable=False),
sa.Column('subscribed', sa.Boolean(), nullable=True),
sa.Column('description', sa.Text(), nullable=False),
@ -26,7 +26,7 @@ def upgrade():
op.create_index(op.f('ix_project_name'), 'project', ['name'], unique=True)
op.create_index(op.f('ix_project_subscribed'), 'project', ['subscribed'], unique=False)
op.create_table('change',
sa.Column('key', sa.Integer(), nullable=False),
sa.Column('key', sa.Integer(), nullable=False, quote=True),
sa.Column('project_key', sa.Integer(), nullable=True),
sa.Column('id', sa.String(length=255), nullable=False),
sa.Column('number', sa.Integer(), nullable=False),
@ -56,7 +56,7 @@ def upgrade():
op.create_index(op.f('ix_change_topic'), 'change', ['topic'], unique=False)
op.create_index(op.f('ix_change_updated'), 'change', ['updated'], unique=False)
op.create_table('approval',
sa.Column('key', sa.Integer(), nullable=False),
sa.Column('key', sa.Integer(), nullable=False, quote=True),
sa.Column('change_key', sa.Integer(), nullable=True),
sa.Column('name', sa.String(length=255), nullable=True),
sa.Column('category', sa.String(length=255), nullable=False),
@ -68,7 +68,7 @@ def upgrade():
op.create_index(op.f('ix_approval_change_key'), 'approval', ['change_key'], unique=False)
op.create_index(op.f('ix_approval_pending'), 'approval', ['pending'], unique=False)
op.create_table('revision',
sa.Column('key', sa.Integer(), nullable=False),
sa.Column('key', sa.Integer(), nullable=False, quote=True),
sa.Column('change_key', sa.Integer(), nullable=True),
sa.Column('number', sa.Integer(), nullable=False),
sa.Column('message', sa.Text(), nullable=False),
@ -80,7 +80,7 @@ def upgrade():
op.create_index(op.f('ix_revision_change_key'), 'revision', ['change_key'], unique=False)
op.create_index(op.f('ix_revision_number'), 'revision', ['number'], unique=False)
op.create_table('label',
sa.Column('key', sa.Integer(), nullable=False),
sa.Column('key', sa.Integer(), nullable=False, quote=True),
sa.Column('change_key', sa.Integer(), nullable=True),
sa.Column('category', sa.String(length=255), nullable=False),
sa.Column('value', sa.Integer(), nullable=False),
@ -90,7 +90,7 @@ def upgrade():
)
op.create_index(op.f('ix_label_change_key'), 'label', ['change_key'], unique=False)
op.create_table('permitted_label',
sa.Column('key', sa.Integer(), nullable=False),
sa.Column('key', sa.Integer(), nullable=False, quote=True),
sa.Column('change_key', sa.Integer(), nullable=True),
sa.Column('category', sa.String(length=255), nullable=False),
sa.Column('value', sa.Integer(), nullable=False),
@ -99,7 +99,7 @@ def upgrade():
)
op.create_index(op.f('ix_permitted_label_change_key'), 'permitted_label', ['change_key'], unique=False)
op.create_table('comment',
sa.Column('key', sa.Integer(), nullable=False),
sa.Column('key', sa.Integer(), nullable=False, quote=True),
sa.Column('revision_key', sa.Integer(), nullable=True),
sa.Column('id', sa.String(length=255), nullable=True),
sa.Column('in_reply_to', sa.String(length=255), nullable=True),
@ -118,7 +118,7 @@ def upgrade():
op.create_index(op.f('ix_comment_pending'), 'comment', ['pending'], unique=False)
op.create_index(op.f('ix_comment_revision_key'), 'comment', ['revision_key'], unique=False)
op.create_table('message',
sa.Column('key', sa.Integer(), nullable=False),
sa.Column('key', sa.Integer(), nullable=False, quote=True),
sa.Column('revision_key', sa.Integer(), nullable=True),
sa.Column('id', sa.String(length=255), nullable=True),
sa.Column('created', sa.DateTime(), nullable=False),

View File

@ -25,9 +25,9 @@ def upgrade():
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")
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")
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)