1"""Add the block data table.
2
3Revision ID: 5f376def75c3
4Revises: 25f4b90a7a42
5Create Date: 2022-02-13 12:52:13.264435
6
7"""
8
9import sqlalchemy as sa
10from alembic import op
11
12import prefect
13
14# revision identifiers, used by Alembic.
15revision = "5f376def75c3"
16down_revision = "25f4b90a7a42"
17branch_labels = None
18depends_on = None
19
20
21def upgrade():
22 # ### commands auto generated by Alembic - please adjust! ###
23 op.create_table(
24 "block_data",
25 sa.Column(
26 "id",
27 prefect.server.utilities.database.UUID(),
28 server_default=sa.text("(GEN_RANDOM_UUID())"),
29 nullable=False,
30 ),
31 sa.Column(
32 "created",
33 prefect.server.utilities.database.Timestamp(timezone=True),
34 server_default=sa.text("CURRENT_TIMESTAMP"),
35 nullable=False,
36 ),
37 sa.Column(
38 "updated",
39 prefect.server.utilities.database.Timestamp(timezone=True),
40 server_default=sa.text("CURRENT_TIMESTAMP"),
41 nullable=False,
42 ),
43 sa.Column("name", sa.String(), nullable=False),
44 sa.Column("blockref", sa.String(), nullable=False),
45 sa.Column(
46 "data",
47 prefect.server.utilities.database.JSON(astext_type=sa.Text()),
48 server_default="{}",
49 nullable=False,
50 ),
51 sa.PrimaryKeyConstraint("id", name=op.f("pk_block_data")),
52 )
53 op.create_index(op.f("ix_block_data__name"), "block_data", ["name"], unique=True)
54 op.create_index(
55 op.f("ix_block_data__updated"), "block_data", ["updated"], unique=False
56 )
57 # ### end Alembic commands ###
58
59
60def downgrade():
61 # ### commands auto generated by Alembic - please adjust! ###
62 op.drop_index(op.f("ix_block_data__updated"), table_name="block_data")
63 op.drop_index(op.f("ix_block_data__name"), table_name="block_data")
64 op.drop_table("block_data")
65 # ### end Alembic commands ###