62 lines
2.0 KiB
Python
62 lines
2.0 KiB
Python
"""Initial migration.
|
|
|
|
Revision ID: d0f896c02017
|
|
Revises:
|
|
Create Date: 2020-06-14 14:50:26.172441
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
from atmosphere.models import BigIntegerDateTime
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = 'd0f896c02017'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('resource',
|
|
sa.Column('uuid', sa.String(length=36), nullable=False),
|
|
sa.Column('type', sa.String(length=32), nullable=False),
|
|
sa.Column('project', sa.String(length=32), nullable=False),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=False),
|
|
sa.PrimaryKeyConstraint('uuid')
|
|
)
|
|
op.create_table('spec',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('type', sa.String(length=32), nullable=True),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_table('instance_spec',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('instance_type', sa.String(length=255), nullable=True),
|
|
sa.Column('state', sa.String(length=255), nullable=True),
|
|
sa.ForeignKeyConstraint(['id'], ['spec.id'], ),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('instance_type', 'state')
|
|
)
|
|
op.create_table('period',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('resource_uuid', sa.String(length=36), nullable=False),
|
|
sa.Column('started_at', BigIntegerDateTime(), nullable=False),
|
|
sa.Column('ended_at', BigIntegerDateTime(), nullable=True),
|
|
sa.Column('spec_id', sa.Integer(), nullable=False),
|
|
sa.ForeignKeyConstraint(['resource_uuid'], ['resource.uuid'], ),
|
|
sa.ForeignKeyConstraint(['spec_id'], ['spec.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_table('period')
|
|
op.drop_table('instance_spec')
|
|
op.drop_table('spec')
|
|
op.drop_table('resource')
|
|
# ### end Alembic commands ###
|