1 """Add the configurations table.
2
3 Revision ID: 28ae48128c75
4 Revises: 7c91cb86dc4e
5 Create Date: 2022-02-17 21:17:37.538086
6
7 """
8
9 import sqlalchemy as sa 1 ctx 1a
10 from alembic import op 1 ctx 1a
11
12 import prefect 1 ctx 1a
13
14 # revision identifiers, used by Alembic.
15 revision = "28ae48128c75" 1 ctx 1a
16 down_revision = "7c91cb86dc4e" 1 ctx 1a
17 branch_labels = None 1 ctx 1a
18 depends_on = None 1 ctx 1a
19
20
21 def upgrade ( ) : 1 ctx 1a
22 # ### commands auto generated by Alembic - please adjust! ###
23 op . create_table ( 1 ctx 1a
24 "configuration" ,
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 ( "key" , sa . String ( ) , nullable = False ) ,
51 sa . Column (
52 "value" ,
53 prefect . server . utilities . database . JSON ( astext_type = sa . Text ( ) ) ,
54 nullable = False ,
55 ) ,
56 sa . PrimaryKeyConstraint ( "id" , name = op . f ( "pk_configuration" ) ) ,
57 sa . UniqueConstraint ( "key" , name = op . f ( "uq_configuration__key" ) ) ,
58 )
59 op . create_index ( 1 ctx 1a
60 op . f ( "ix_configuration__key" ) , "configuration" , [ "key" ] , unique = False
61 )
62 op . create_index ( 1 ctx 1a
63 op . f ( "ix_configuration__updated" ) , "configuration" , [ "updated" ] , unique = False
64 )
65 # ### end Alembic commands ###
66
67
68 def downgrade ( ) : 1 ctx 1a
69 # ### commands auto generated by Alembic - please adjust! ###
70 op . drop_index ( op . f ( "ix_configuration__updated" ) , table_name = "configuration" )
71 op . drop_index ( op . f ( "ix_configuration__key" ) , table_name = "configuration" )
72 op . drop_table ( "configuration" )
73 # ### end Alembic commands ###