|
|
@ -8,7 +8,6 @@ Create Date: 2021-03-13 20:29:10.062757 |
|
|
|
from alembic import op |
|
|
|
import sqlalchemy as sa |
|
|
|
|
|
|
|
|
|
|
|
# revision identifiers, used by Alembic. |
|
|
|
from sqlalchemy.exc import OperationalError |
|
|
|
|
|
|
@ -17,6 +16,7 @@ down_revision = None |
|
|
|
branch_labels = None |
|
|
|
depends_on = None |
|
|
|
|
|
|
|
|
|
|
|
def ignore_duplicate(fn): |
|
|
|
try: |
|
|
|
fn() |
|
|
@ -24,6 +24,7 @@ def ignore_duplicate(fn): |
|
|
|
if "duplicate" in str(e): |
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
def upgrade(): |
|
|
|
# ### commands auto generated by Alembic - please adjust! ### |
|
|
|
try: |
|
|
@ -32,7 +33,8 @@ def upgrade(): |
|
|
|
sa.Column('key', sa.String(), nullable=True), |
|
|
|
sa.Column('user_id', sa.Integer(), nullable=True), |
|
|
|
sa.Column('created_date', sa.DateTime(), nullable=True), |
|
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='fk_user_api_key_user_id', onupdate='CASCADE', ondelete='CASCADE'), |
|
|
|
sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='fk_user_api_key_user_id', |
|
|
|
onupdate='CASCADE', ondelete='CASCADE'), |
|
|
|
sa.PrimaryKeyConstraint('id'), |
|
|
|
sa.UniqueConstraint('key') |
|
|
|
) |
|
|
@ -51,7 +53,8 @@ def upgrade(): |
|
|
|
batch_op.drop_constraint("fk_peer_server_id_server", type_="foreignkey") |
|
|
|
|
|
|
|
with op.batch_alter_table('peer', schema=None) as batch_op: |
|
|
|
batch_op.create_foreign_key('fk_peer_server_id_server', 'server', ['server_id'], ['id'], onupdate='CASCADE', ondelete='CASCADE') |
|
|
|
batch_op.create_foreign_key('fk_peer_server_id_server', 'server', ['server_id'], ['id'], onupdate='CASCADE', |
|
|
|
ondelete='CASCADE') |
|
|
|
|
|
|
|
ignore_duplicate(lambda: op.add_column('peer', sa.Column('configuration', sa.Text(), nullable=True))) |
|
|
|
ignore_duplicate(lambda: op.add_column('peer', sa.Column('keep_alive', sa.Integer(), nullable=True))) |
|
|
@ -60,12 +63,10 @@ def upgrade(): |
|
|
|
ignore_duplicate(lambda: op.add_column('peer', sa.Column('shared_key', sa.Text(), nullable=True))) |
|
|
|
ignore_duplicate(lambda: op.add_column('peer', sa.Column('v6_address', sa.String(), nullable=True))) |
|
|
|
|
|
|
|
|
|
|
|
# op.drop_constraint(None, 'peer', type_='foreignkey') |
|
|
|
# |
|
|
|
# op.drop_column('peer', 'server') |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
with op.batch_alter_table('peer', schema=None) as batch_op: |
|
|
|
batch_op.drop_column("server") |
|
|
@ -82,7 +83,6 @@ def upgrade(): |
|
|
|
ignore_duplicate(lambda: op.add_column('server', sa.Column('v6_subnet', sa.Integer(), nullable=False))) |
|
|
|
# op.create_unique_constraint(None, 'server', ['v6_address']) |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
with op.batch_alter_table('server', schema=None) as batch_op: |
|
|
|
batch_op.drop_column("shared_key") |
|
|
|