"""DB Games model migrations

Revision ID: 89944f8b35b3
Revises: 
Create Date: 2020-11-14 03:49:03.255055

"""
import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = "89944f8b35b3"
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "company",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=250), nullable=False),
        sa.Column("creation_year", sa.DateTime(), nullable=True),
        sa.Column("description", sa.String(length=500), nullable=True),
        sa.Column("logo", sa.String(length=500), nullable=True),
        sa.Column("is_publisher", sa.Boolean(), nullable=True),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_table(
        "franchise",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("title", sa.String(length=250), nullable=False),
        sa.Column("first_release", sa.DateTime(), nullable=True),
        sa.Column("description", sa.String(length=250), nullable=True),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_table(
        "console",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=250), nullable=False),
        sa.Column("release_year", sa.DateTime(), nullable=False),
        sa.Column("description", sa.String(length=500), nullable=True),
        sa.Column("cover", sa.String(length=500), nullable=True),
        sa.Column("motto", sa.String(length=100), nullable=False),
        sa.Column("company_id", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(["company_id"], ["company.id"], ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_table(
        "game",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=250), nullable=False),
        sa.Column("publication_year", sa.DateTime(), nullable=True),
        sa.Column("score", sa.Integer(), nullable=True),
        sa.Column("description", sa.String(length=500), nullable=True),
        sa.Column("cover", sa.String(length=500), nullable=True),
        sa.Column("franchise_id", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(["franchise_id"], ["franchise.id"], ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_table(
        "franchiseassociation",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("franchise_id", sa.Integer(), nullable=True),
        sa.Column("game_id", sa.Integer(), nullable=True),
        sa.Column("console_id", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(["console_id"], ["console.id"], ondelete="CASCADE"),
        sa.ForeignKeyConstraint(["franchise_id"], ["franchise.id"], ondelete="CASCADE"),
        sa.ForeignKeyConstraint(["game_id"], ["game.id"], ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_table(
        "game_console_table",
        sa.Column("game_id", sa.Integer(), nullable=True),
        sa.Column("console_id", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ["console_id"],
            ["console.id"],
        ),
        sa.ForeignKeyConstraint(
            ["game_id"],
            ["game.id"],
        ),
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("game_console_table")
    op.drop_table("franchiseassociation")
    op.drop_table("game")
    op.drop_table("console")
    op.drop_table("franchise")
    op.drop_table("company")
    # ### end Alembic commands ###

"""DB Games model migrations

Revision ID: 89944f8b35b3
Revises: 
Create Date: 2020-11-14 03:49:03.255055

"""
import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = "89944f8b35b3"
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "company",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=250), nullable=False),
        sa.Column("creation_year", sa.DateTime(), nullable=True),
        sa.Column("description", sa.String(length=500), nullable=True),
        sa.Column("logo", sa.String(length=500), nullable=True),
        sa.Column("is_publisher", sa.Boolean(), nullable=True),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_table(
        "franchise",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("title", sa.String(length=250), nullable=False),
        sa.Column("first_release", sa.DateTime(), nullable=True),
        sa.Column("description", sa.String(length=250), nullable=True),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_table(
        "console",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=250), nullable=False),
        sa.Column("release_year", sa.DateTime(), nullable=False),
        sa.Column("description", sa.String(length=500), nullable=True),
        sa.Column("cover", sa.String(length=500), nullable=True),
        sa.Column("motto", sa.String(length=100), nullable=False),
        sa.Column("company_id", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(["company_id"], ["company.id"], ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_table(
        "game",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("name", sa.String(length=250), nullable=False),
        sa.Column("publication_year", sa.DateTime(), nullable=True),
        sa.Column("score", sa.Integer(), nullable=True),
        sa.Column("description", sa.String(length=500), nullable=True),
        sa.Column("cover", sa.String(length=500), nullable=True),
        sa.Column("franchise_id", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(["franchise_id"], ["franchise.id"], ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_table(
        "franchiseassociation",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("franchise_id", sa.Integer(), nullable=True),
        sa.Column("game_id", sa.Integer(), nullable=True),
        sa.Column("console_id", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(["console_id"], ["console.id"], ondelete="CASCADE"),
        sa.ForeignKeyConstraint(["franchise_id"], ["franchise.id"], ondelete="CASCADE"),
        sa.ForeignKeyConstraint(["game_id"], ["game.id"], ondelete="CASCADE"),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_table(
        "game_console_table",
        sa.Column("game_id", sa.Integer(), nullable=True),
        sa.Column("console_id", sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ["console_id"],
            ["console.id"],
        ),
        sa.ForeignKeyConstraint(
            ["game_id"],
            ["game.id"],
        ),
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("game_console_table")
    op.drop_table("franchiseassociation")
    op.drop_table("game")
    op.drop_table("console")
    op.drop_table("franchise")
    op.drop_table("company")
    # ### end Alembic commands ###

DB Games model migrations  Revision ID: 89944f8b35b3 Revises:  Create Date: 2020-11-14 03:49:03.255055 # revision identifiers, used by Alembic. # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ### # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ###