awesome-fastapi-projects/migrations/versions/a48ca845cfe5_first_commit.py
Marcelo Trylesinski 65c21c0bd4 Add structure
2021-11-17 10:10:33 +01:00

64 lines
2.0 KiB
Python

"""First commit
Revision ID: a48ca845cfe5
Revises:
Create Date: 2021-11-17 09:32:18.940645
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "a48ca845cfe5"
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"package",
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("updated_at", sa.DateTime(), nullable=True),
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("name", sa.String(), nullable=False),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"repository",
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("updated_at", sa.DateTime(), nullable=True),
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("full_name", sa.String(), nullable=False),
sa.Column("html_url", sa.String(), nullable=False),
sa.Column("clone_url", sa.String(), nullable=False),
sa.Column("stargazers", sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint("id"),
)
op.create_table(
"dependency",
sa.Column("created_at", sa.DateTime(), nullable=True),
sa.Column("updated_at", sa.DateTime(), nullable=True),
sa.Column("repository_id", sa.Integer(), nullable=False),
sa.Column("package_id", sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(
["package_id"],
["package.id"],
),
sa.ForeignKeyConstraint(
["repository_id"],
["repository.id"],
),
sa.PrimaryKeyConstraint("repository_id", "package_id"),
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("dependency")
op.drop_table("repository")
op.drop_table("package")
# ### end Alembic commands ###