-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path2024_06_05_2051-4882ac82d08b_removed_legacy_genres.py
174 lines (165 loc) · 5.43 KB
/
2024_06_05_2051-4882ac82d08b_removed_legacy_genres.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
"""Removed legacy genres
Revision ID: 4882ac82d08b
Revises: 8e32142fab6e
Create Date: 2024-06-05 20:51:22.512090
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "4882ac82d08b"
down_revision = "8e32142fab6e"
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("service_relation_manga_genres")
op.drop_table("service_relation_anime_genres")
op.drop_index(
"ix_service_content_anime_genres_content_id",
table_name="service_content_anime_genres",
)
op.drop_index(
"ix_service_content_anime_genres_slug",
table_name="service_content_anime_genres",
)
op.drop_index(
"ix_service_content_anime_genres_type",
table_name="service_content_anime_genres",
)
op.drop_table("service_content_anime_genres")
op.drop_index(
"ix_service_content_manga_genres_content_id",
table_name="service_content_manga_genres",
)
op.drop_index(
"ix_service_content_manga_genres_slug",
table_name="service_content_manga_genres",
)
op.drop_index(
"ix_service_content_manga_genres_type",
table_name="service_content_manga_genres",
)
op.drop_table("service_content_manga_genres")
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"service_relation_manga_genres",
sa.Column("manga_id", sa.UUID(), autoincrement=False, nullable=False),
sa.Column("genre_id", sa.UUID(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["genre_id"],
["service_content_manga_genres.id"],
name="service_relation_manga_genres_genre_id_fkey",
),
sa.ForeignKeyConstraint(
["manga_id"],
["service_content_manga.id"],
name="service_relation_manga_genres_manga_id_fkey",
),
sa.PrimaryKeyConstraint(
"manga_id", "genre_id", name="service_relation_manga_genres_pkey"
),
)
op.create_table(
"service_content_manga_genres",
sa.Column(
"name_en", sa.VARCHAR(length=64), autoincrement=False, nullable=True
),
sa.Column(
"name_ua", sa.VARCHAR(length=64), autoincrement=False, nullable=True
),
sa.Column(
"type", sa.VARCHAR(length=32), autoincrement=False, nullable=False
),
sa.Column("id", sa.UUID(), autoincrement=False, nullable=False),
sa.Column(
"content_id",
sa.VARCHAR(length=36),
autoincrement=False,
nullable=False,
),
sa.Column(
"slug", sa.VARCHAR(length=255), autoincrement=False, nullable=False
),
sa.PrimaryKeyConstraint("id", name="service_content_manga_genres_pkey"),
)
op.create_index(
"ix_service_content_manga_genres_type",
"service_content_manga_genres",
["type"],
unique=False,
)
op.create_index(
"ix_service_content_manga_genres_slug",
"service_content_manga_genres",
["slug"],
unique=False,
)
op.create_index(
"ix_service_content_manga_genres_content_id",
"service_content_manga_genres",
["content_id"],
unique=True,
)
op.create_table(
"service_content_anime_genres",
sa.Column(
"name_en", sa.VARCHAR(length=64), autoincrement=False, nullable=True
),
sa.Column(
"name_ua", sa.VARCHAR(length=64), autoincrement=False, nullable=True
),
sa.Column(
"type", sa.VARCHAR(length=32), autoincrement=False, nullable=False
),
sa.Column("id", sa.UUID(), autoincrement=False, nullable=False),
sa.Column(
"content_id",
sa.VARCHAR(length=36),
autoincrement=False,
nullable=False,
),
sa.Column(
"slug", sa.VARCHAR(length=255), autoincrement=False, nullable=False
),
sa.PrimaryKeyConstraint("id", name="service_content_anime_genres_pkey"),
postgresql_ignore_search_path=False,
)
op.create_index(
"ix_service_content_anime_genres_type",
"service_content_anime_genres",
["type"],
unique=False,
)
op.create_index(
"ix_service_content_anime_genres_slug",
"service_content_anime_genres",
["slug"],
unique=False,
)
op.create_index(
"ix_service_content_anime_genres_content_id",
"service_content_anime_genres",
["content_id"],
unique=True,
)
op.create_table(
"service_relation_anime_genres",
sa.Column("anime_id", sa.UUID(), autoincrement=False, nullable=False),
sa.Column("genre_id", sa.UUID(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["anime_id"],
["service_content_anime.id"],
name="service_relation_anime_genres_anime_id_fkey",
),
sa.ForeignKeyConstraint(
["genre_id"],
["service_content_anime_genres.id"],
name="service_relation_anime_genres_genre_id_fkey",
),
sa.PrimaryKeyConstraint(
"anime_id", "genre_id", name="service_relation_anime_genres_pkey"
),
)
# ### end Alembic commands ###