1"""Automation event follower
2
3Revision ID: 916718e8330f
4Revises: bd6efa529f03
5Create Date: 2024-04-09 12:56:58.865815
6
7"""
8
9import sqlalchemy as sa
10from alembic import op
11
12import prefect
13import prefect.server.utilities.database
14from prefect.server.events.schemas.events import ReceivedEvent
15
16# revision identifiers, used by Alembic.
17revision = "916718e8330f"
18down_revision = "bd6efa529f03"
19branch_labels = None
20depends_on = None
21
22
23def upgrade():
24 # ### commands auto generated by Alembic - please adjust! ###
25 op.create_table(
26 "automation_event_follower",
27 sa.Column(
28 "leader_event_id", prefect.server.utilities.database.UUID(), nullable=False
29 ),
30 sa.Column(
31 "follower_event_id",
32 prefect.server.utilities.database.UUID(),
33 nullable=False,
34 ),
35 sa.Column(
36 "received",
37 prefect.server.utilities.database.Timestamp(timezone=True),
38 nullable=False,
39 ),
40 sa.Column(
41 "follower",
42 prefect.server.utilities.database.Pydantic(ReceivedEvent),
43 nullable=False,
44 ),
45 sa.Column(
46 "id",
47 prefect.server.utilities.database.UUID(),
48 server_default=sa.text("(GEN_RANDOM_UUID())"),
49 nullable=False,
50 ),
51 sa.Column(
52 "created",
53 prefect.server.utilities.database.Timestamp(timezone=True),
54 server_default=sa.text("CURRENT_TIMESTAMP"),
55 nullable=False,
56 ),
57 sa.Column(
58 "updated",
59 prefect.server.utilities.database.Timestamp(timezone=True),
60 server_default=sa.text("CURRENT_TIMESTAMP"),
61 nullable=False,
62 ),
63 sa.PrimaryKeyConstraint("id", name=op.f("pk_automation_event_follower")),
64 sa.UniqueConstraint(
65 "follower_event_id",
66 name=op.f("uq_automation_event_follower__follower_event_id"),
67 ),
68 )
69 op.create_index(
70 op.f("ix_automation_event_follower__leader_event_id"),
71 "automation_event_follower",
72 ["leader_event_id"],
73 unique=False,
74 )
75 op.create_index(
76 op.f("ix_automation_event_follower__received"),
77 "automation_event_follower",
78 ["received"],
79 unique=False,
80 )
81 op.create_index(
82 op.f("ix_automation_event_follower__updated"),
83 "automation_event_follower",
84 ["updated"],
85 unique=False,
86 )
87
88
89def downgrade():
90 op.drop_index(
91 op.f("ix_automation_event_follower__updated"),
92 table_name="automation_event_follower",
93 )
94 op.drop_index(
95 op.f("ix_automation_event_follower__received"),
96 table_name="automation_event_follower",
97 )
98 op.drop_index(
99 op.f("ix_automation_event_follower__leader_event_id"),
100 table_name="automation_event_follower",
101 )
102 op.drop_table("automation_event_follower")
103 # ### end Alembic commands ###