-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path2024_12_18_2111-d2bd8dd78891_added_comments_count_field.py
93 lines (85 loc) · 2.78 KB
/
2024_12_18_2111-d2bd8dd78891_added_comments_count_field.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
"""Added comments_count field
Revision ID: d2bd8dd78891
Revises: 23086dc47605
Create Date: 2024-12-18 21:11:53.367858
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "d2bd8dd78891"
down_revision = "23086dc47605"
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("service_comment_votes")
op.add_column(
"service_collections",
sa.Column(
"comments_count", sa.Integer(), nullable=False, server_default="0"
),
)
op.add_column(
"service_content_anime",
sa.Column(
"comments_count", sa.Integer(), nullable=False, server_default="0"
),
)
op.add_column(
"service_content_manga",
sa.Column(
"comments_count", sa.Integer(), nullable=False, server_default="0"
),
)
op.add_column(
"service_content_novel",
sa.Column(
"comments_count", sa.Integer(), nullable=False, server_default="0"
),
)
op.add_column(
"service_edits",
sa.Column(
"comments_count", sa.Integer(), nullable=False, server_default="0"
),
)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("service_edits", "comments_count")
op.drop_column("service_content_novel", "comments_count")
op.drop_column("service_content_manga", "comments_count")
op.drop_column("service_content_anime", "comments_count")
op.drop_column("service_collections", "comments_count")
op.create_table(
"service_comment_votes",
sa.Column("user_id", sa.UUID(), autoincrement=False, nullable=True),
sa.Column("score", sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column("comment_id", sa.UUID(), autoincrement=False, nullable=True),
sa.Column("id", sa.UUID(), autoincrement=False, nullable=False),
sa.Column(
"created",
postgresql.TIMESTAMP(),
autoincrement=False,
nullable=False,
),
sa.Column(
"updated",
postgresql.TIMESTAMP(),
autoincrement=False,
nullable=False,
),
sa.ForeignKeyConstraint(
["comment_id"],
["service_comments.id"],
name="service_comment_votes_comment_id_fkey",
),
sa.ForeignKeyConstraint(
["user_id"],
["service_users.id"],
name="service_comment_votes_user_id_fkey",
),
sa.PrimaryKeyConstraint("id", name="service_comment_votes_pkey"),
)
# ### end Alembic commands ###