From e570212be4b4c285dd069de641f5498097a62671 Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Mon, 31 Jul 2023 16:08:49 +0100 Subject: [PATCH] Add migration to add video table --- .../d4e3e1bf95eb_add_the_video_table.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 via/migrations/versions/d4e3e1bf95eb_add_the_video_table.py diff --git a/via/migrations/versions/d4e3e1bf95eb_add_the_video_table.py b/via/migrations/versions/d4e3e1bf95eb_add_the_video_table.py new file mode 100644 index 00000000..3353ab6b --- /dev/null +++ b/via/migrations/versions/d4e3e1bf95eb_add_the_video_table.py @@ -0,0 +1,32 @@ +"""Add the video table. + +Revision ID: d4e3e1bf95eb +Revises: +""" +import sqlalchemy as sa +from alembic import op +from sqlalchemy.dialects import postgresql + +revision = "d4e3e1bf95eb" +down_revision = "9a37efe13a91" + + +def upgrade() -> None: + op.create_table( + "video", + sa.Column( + "created", sa.DateTime(), server_default=sa.text("now()"), nullable=False + ), + sa.Column( + "updated", sa.DateTime(), server_default=sa.text("now()"), nullable=False + ), + sa.Column("id", sa.Integer(), autoincrement=True, nullable=False), + sa.Column("video_id", sa.String(), nullable=False), + sa.Column("title", sa.String(), nullable=False), + sa.PrimaryKeyConstraint("id", name=op.f("pk_video")), + sa.UniqueConstraint("video_id", name=op.f("uq_video_video_id")), + ) + + +def downgrade() -> None: + op.drop_table("video")