MIGRATION: drop foreign keys on logentry table
This migration generates the following for MySQL: BEGIN; -- Running upgrade 1093d8b212bb -> 6243159408b5 ALTER TABLE logentry DROP FOREIGN KEY fk_logentry_account_id_user; ALTER TABLE logentry DROP FOREIGN KEY fk_logentry_repository_id_repository; ALTER TABLE logentry DROP FOREIGN KEY fk_logentry_performer_id_user; UPDATE alembic_version SET version_num='6243159408b5' WHERE alembic_version.version_num = '1093d8b212bb'; COMMIT;
This commit is contained in:
parent
e05bc8bf7d
commit
052c31752b
2 changed files with 29 additions and 4 deletions
|
@ -739,10 +739,9 @@ class LogEntryKind(BaseModel):
|
|||
|
||||
class LogEntry(BaseModel):
|
||||
kind = ForeignKeyField(LogEntryKind)
|
||||
account = QuayUserField(index=True, related_name='account')
|
||||
performer = QuayUserField(allows_robots=True, index=True, null=True,
|
||||
related_name='performer', robot_null_delete=True)
|
||||
repository = ForeignKeyField(Repository, null=True)
|
||||
account = IntegerField(index=True, db_column='account_id')
|
||||
performer = IntegerField(index=True, null=True, db_column='performer_id')
|
||||
repository = IntegerField(index=True, null=True, db_column='repository_id')
|
||||
datetime = DateTimeField(default=datetime.now, index=True)
|
||||
ip = CharField(null=True)
|
||||
metadata_json = TextField(default='{}')
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
"""remove logentry fk constraint
|
||||
|
||||
Revision ID: 6243159408b5
|
||||
Revises: 1093d8b212bb
|
||||
Create Date: 2016-08-05 13:23:46.219759
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '6243159408b5'
|
||||
down_revision = '790d91952fa8'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
def upgrade(tables):
|
||||
op.drop_constraint(u'fk_logentry_account_id_user', 'logentry', type_='foreignkey')
|
||||
op.drop_constraint(u'fk_logentry_repository_id_repository', 'logentry', type_='foreignkey')
|
||||
op.drop_constraint(u'fk_logentry_performer_id_user', 'logentry', type_='foreignkey')
|
||||
|
||||
|
||||
def downgrade(tables):
|
||||
op.create_foreign_key(u'fk_logentry_performer_id_user', 'logentry', 'user', ['performer_id'], ['id'])
|
||||
op.create_foreign_key(u'fk_logentry_repository_id_repository', 'logentry', 'repository', ['repository_id'], ['id'])
|
||||
op.create_foreign_key(u'fk_logentry_account_id_user', 'logentry', 'user', ['account_id'], ['id'])
|
Reference in a new issue