"""Initial migrations

Revision ID: cc927fe47c8f
Revises: 
Create Date: 2021-08-20 23:16:00.708943

"""
import sqlalchemy as sa
from alembic import op

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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "urls",
        sa.Column("id", sa.String(length=31), nullable=False),
        sa.Column("base_address", sa.String(length=127), nullable=False),
        sa.Column("ip", sa.String(length=31), nullable=True),
        sa.Column("created_at", sa.DateTime(), nullable=True),
        sa.PrimaryKeyConstraint("id"),
    )
    op.create_index(op.f("ix_urls_base_address"), "urls", ["base_address"], unique=True)
    op.create_table(
        "view",
        sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
        sa.Column("url_id", sa.String(length=31), nullable=True),
        sa.ForeignKeyConstraint(
            ["url_id"],
            ["urls.id"],
        ),
        sa.PrimaryKeyConstraint("id"),
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table("view")
    op.drop_index(op.f("ix_urls_base_address"), table_name="urls")
    op.drop_table("urls")
    # ### end Alembic commands ###
