Coverage for /usr/local/lib/python3.12/site-packages/prefect/server/database/_migrations/versions/sqlite/2022_02_04_093838_619bea85701a_block_data.py: 80%
15 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 13:38 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-12-05 13:38 +0000
1"""Add the block data table.
3Revision ID: 619bea85701a
4Revises: 9725c1cbee35
5Create Date: 2022-02-04 09:38:38.324086
7"""
9import sqlalchemy as sa 1a
10from alembic import op 1a
12import prefect 1a
14# revision identifiers, used by Alembic.
15revision = "619bea85701a" 1a
16down_revision = "9725c1cbee35" 1a
17branch_labels = None 1a
18depends_on = None 1a
21def upgrade(): 1a
22 # ### commands auto generated by Alembic - please adjust! ###
23 op.create_table( 1a
24 "block_data",
25 sa.Column(
26 "id",
27 prefect.server.utilities.database.UUID(),
28 server_default=sa.text(
29 "(\n (\n lower(hex(randomblob(4))) \n || '-' \n "
30 " || lower(hex(randomblob(2))) \n || '-4' \n ||"
31 " substr(lower(hex(randomblob(2))),2) \n || '-' \n ||"
32 " substr('89ab',abs(random()) % 4 + 1, 1) \n ||"
33 " substr(lower(hex(randomblob(2))),2) \n || '-' \n ||"
34 " lower(hex(randomblob(6)))\n )\n )"
35 ),
36 nullable=False,
37 ),
38 sa.Column(
39 "created",
40 prefect.server.utilities.database.Timestamp(timezone=True),
41 server_default=sa.text("(strftime('%Y-%m-%d %H:%M:%f000', 'now'))"),
42 nullable=False,
43 ),
44 sa.Column(
45 "updated",
46 prefect.server.utilities.database.Timestamp(timezone=True),
47 server_default=sa.text("(strftime('%Y-%m-%d %H:%M:%f000', 'now'))"),
48 nullable=False,
49 ),
50 sa.Column("name", sa.String(), nullable=False),
51 sa.Column("blockref", sa.String(), nullable=False),
52 sa.Column(
53 "data",
54 prefect.server.utilities.database.JSON(astext_type=sa.Text()),
55 server_default="{}",
56 nullable=False,
57 ),
58 sa.PrimaryKeyConstraint("id", name=op.f("pk_block_data")),
59 )
60 op.create_index(op.f("ix_block_data__name"), "block_data", ["name"], unique=True) 1a
61 op.create_index( 1a
62 op.f("ix_block_data__updated"), "block_data", ["updated"], unique=False
63 )
64 # ### end Alembic commands ###
67def downgrade(): 1a
68 # ### commands auto generated by Alembic - please adjust! ###
69 op.drop_index(op.f("ix_block_data__updated"), table_name="block_data")
70 op.drop_index(op.f("ix_block_data__name"), table_name="block_data")
71 op.drop_table("block_data")
72 # ### end Alembic commands ###