Skip to content
Snippets Groups Projects
Commit 6e703fb5 authored by Erik Reid's avatar Erik Reid
Browse files

migration for initial tables

parent 5e80096d
No related branches found
No related tags found
No related merge requests found
...@@ -3,5 +3,6 @@ ...@@ -3,5 +3,6 @@
# make sure the right line is un / commented depending on which schema you want # make sure the right line is un / commented depending on which schema you want
# a migration for # a migration for
script_location = migrations script_location = migrations
# change this to run migrations from the command line sqlalchemy.url = sqlite:////absolute/path/to/foo.db
sqlalchemy.url = mysql://dummy:dummy-pass@localhost/resources_test # or here is an example of a mysql dsn
# sqlalchemy.url = mysql://dummy:dummy-pass@localhost/resources_db_name
"""create initial tables """initial tables
Revision ID: 1983660b3e64 Revision ID: 1ec562888fd6
Revises: Revises:
Create Date: 2022-12-18 14:16:34.695912 Create Date: 2023-03-20 07:05:18.984767
""" """
from alembic import op from alembic import op
...@@ -10,58 +10,66 @@ import sqlalchemy as sa ...@@ -10,58 +10,66 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic. # revision identifiers, used by Alembic.
revision = '1983660b3e64' revision = '1ec562888fd6'
down_revision = None down_revision = None
branch_labels = None branch_labels = None
depends_on = None depends_on = None
def upgrade() -> None: def upgrade() -> None:
op.create_table( op.create_table(
'nodes', 'routers',
sa.Column('id', sa.Integer, primary_key=True), sa.Column('id', sa.Integer, primary_key=True),
sa.Column('fqdn', sa.String(256), nullable=False)) sa.Column('fqdn', sa.String(256), nullable=False))
op.create_table( op.create_table(
'line_cards', 'lags',
sa.Column('id', sa.Integer, primary_key=True), sa.Column('id', sa.Integer, primary_key=True),
sa.Column('slot', sa.Integer, nullable=False), sa.Column('name', sa.String, nullable=False),
sa.Column('model', sa.String(256), nullable=False), sa.Column(
sa.Column('serial', sa.String(256), nullable=False), 'availability',
sa.Column('description', sa.String(256), nullable=False), sa.Enum('AVAILABLE', 'USED', 'RESERVED', name='lag_availability'),
nullable=False),
sa.Column( sa.Column(
'node_id', 'router_id',
sa.Integer, sa.Integer,
sa.ForeignKey('nodes.id'), sa.ForeignKey('routers.id'),
nullable=False)) nullable=False))
op.create_table( op.create_table(
'ports', 'physical_interfaces',
sa.Column('id', sa.Integer, primary_key=True), sa.Column('id', sa.Integer, primary_key=True),
sa.Column('pic', sa.Integer, nullable=False), sa.Column('name', sa.String, nullable=False),
sa.Column('position', sa.Integer, nullable=False),
sa.Column('interface', sa.String(256), nullable=True),
sa.Column('cable', sa.String(256), nullable=True),
sa.Column('cable', sa.String(256), nullable=True),
sa.Column( sa.Column(
'line_card_id', 'availability',
sa.Enum('AVAILABLE', 'USED', 'RESERVED', name='lag_availability'),
nullable=False),
sa.Column(
'router_id',
sa.Integer, sa.Integer,
sa.ForeignKey('line_cards.id'), sa.ForeignKey('routers.id'),
nullable=False)) nullable=False),
sa.Column(
'lag_id',
sa.Integer,
sa.ForeignKey('lags.id'),
nullable=True))
op.create_table( op.create_table(
'port_speed_capabilities', 'logical_interfaces',
sa.Column('id', sa.Integer, primary_key=True), sa.Column('id', sa.Integer, primary_key=True),
sa.Column('speed', sa.String(256), nullable=True), sa.Column('name', sa.String, nullable=False),
sa.Column( sa.Column(
'port_id', 'physical_id',
sa.Integer, sa.Integer,
sa.ForeignKey('ports.id'), sa.ForeignKey('physical_interfaces.id'),
nullable=False)) nullable=False))
def downgrade() -> None: def downgrade() -> None:
op.drop_table('port_speed_capabilities') op.drop_table('logical_interfaces')
op.drop_table('ports') op.drop_table('physical_interfaces')
op.drop_table('line_cards') op.drop_table('lags')
op.drop_table('nodes') op.drop_table('routers')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment