Skip to content

Commit d22e029

Browse files
committed
fixes migration downgrade
1 parent 41e964b commit d22e029

File tree

1 file changed

+62
-62
lines changed

1 file changed

+62
-62
lines changed

packages/postgres-database/src/simcore_postgres_database/migration/versions/061607911a22_drop_projects_version_control.py

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ def upgrade():
2727

2828
def downgrade():
2929

30+
op.create_table(
31+
"projects_vc_snapshots",
32+
sa.Column("checksum", sa.VARCHAR(), autoincrement=False, nullable=False),
33+
sa.Column(
34+
"content",
35+
postgresql.JSONB(astext_type=sa.Text()),
36+
server_default=sa.text("'{}'::jsonb"),
37+
autoincrement=False,
38+
nullable=False,
39+
),
40+
sa.PrimaryKeyConstraint("checksum", name="projects_vc_snapshots_pkey"),
41+
postgresql_ignore_search_path=False,
42+
)
43+
3044
op.create_table(
3145
"projects_vc_repos",
3246
sa.Column(
@@ -64,51 +78,6 @@ def downgrade():
6478
postgresql_ignore_search_path=False,
6579
)
6680

67-
op.create_table(
68-
"projects_vc_snapshots",
69-
sa.Column("checksum", sa.VARCHAR(), autoincrement=False, nullable=False),
70-
sa.Column(
71-
"content",
72-
postgresql.JSONB(astext_type=sa.Text()),
73-
server_default=sa.text("'{}'::jsonb"),
74-
autoincrement=False,
75-
nullable=False,
76-
),
77-
sa.PrimaryKeyConstraint("checksum", name="projects_vc_snapshots_pkey"),
78-
postgresql_ignore_search_path=False,
79-
)
80-
81-
op.create_table(
82-
"projects_vc_heads",
83-
sa.Column("repo_id", sa.BIGINT(), autoincrement=False, nullable=False),
84-
sa.Column("head_branch_id", sa.BIGINT(), autoincrement=False, nullable=True),
85-
sa.Column(
86-
"modified",
87-
postgresql.TIMESTAMP(),
88-
server_default=sa.text("now()"),
89-
autoincrement=False,
90-
nullable=False,
91-
),
92-
sa.ForeignKeyConstraint(
93-
["head_branch_id"],
94-
["projects_vc_branches.id"],
95-
name="fk_projects_vc_heads_head_branch_id",
96-
onupdate="CASCADE",
97-
ondelete="CASCADE",
98-
),
99-
sa.ForeignKeyConstraint(
100-
["repo_id"],
101-
["projects_vc_repos.id"],
102-
name="projects_vc_branches_repo_id",
103-
onupdate="CASCADE",
104-
ondelete="CASCADE",
105-
),
106-
sa.PrimaryKeyConstraint("repo_id", name="projects_vc_heads_pkey"),
107-
sa.UniqueConstraint(
108-
"head_branch_id", name="projects_vc_heads_head_branch_id_key"
109-
),
110-
)
111-
11281
op.create_table(
11382
"projects_vc_commits",
11483
sa.Column(
@@ -156,13 +125,11 @@ def downgrade():
156125
)
157126

158127
op.create_table(
159-
"projects_vc_tags",
128+
"projects_vc_branches",
160129
sa.Column("id", sa.BIGINT(), autoincrement=True, nullable=False),
161130
sa.Column("repo_id", sa.BIGINT(), autoincrement=False, nullable=False),
162-
sa.Column("commit_id", sa.BIGINT(), autoincrement=False, nullable=False),
131+
sa.Column("head_commit_id", sa.BIGINT(), autoincrement=False, nullable=True),
163132
sa.Column("name", sa.VARCHAR(), autoincrement=False, nullable=True),
164-
sa.Column("message", sa.VARCHAR(), autoincrement=False, nullable=True),
165-
sa.Column("hidden", sa.BOOLEAN(), autoincrement=False, nullable=True),
166133
sa.Column(
167134
"created",
168135
postgresql.TIMESTAMP(),
@@ -178,29 +145,31 @@ def downgrade():
178145
nullable=False,
179146
),
180147
sa.ForeignKeyConstraint(
181-
["commit_id"],
148+
["head_commit_id"],
182149
["projects_vc_commits.id"],
183-
name="fk_projects_vc_tags_commit_id",
150+
name="fk_projects_vc_branches_head_commit_id",
184151
onupdate="CASCADE",
185-
ondelete="CASCADE",
152+
ondelete="RESTRICT",
186153
),
187154
sa.ForeignKeyConstraint(
188155
["repo_id"],
189156
["projects_vc_repos.id"],
190-
name="fk_projects_vc_tags_repo_id",
157+
name="projects_vc_branches_repo_id",
191158
onupdate="CASCADE",
192159
ondelete="CASCADE",
193160
),
194-
sa.PrimaryKeyConstraint("id", name="projects_vc_tags_pkey"),
195-
sa.UniqueConstraint("name", "repo_id", name="repo_tag_uniqueness"),
161+
sa.PrimaryKeyConstraint("id", name="projects_vc_branches_pkey"),
162+
sa.UniqueConstraint("name", "repo_id", name="repo_branch_uniqueness"),
196163
)
197164

198165
op.create_table(
199-
"projects_vc_branches",
166+
"projects_vc_tags",
200167
sa.Column("id", sa.BIGINT(), autoincrement=True, nullable=False),
201168
sa.Column("repo_id", sa.BIGINT(), autoincrement=False, nullable=False),
202-
sa.Column("head_commit_id", sa.BIGINT(), autoincrement=False, nullable=True),
169+
sa.Column("commit_id", sa.BIGINT(), autoincrement=False, nullable=False),
203170
sa.Column("name", sa.VARCHAR(), autoincrement=False, nullable=True),
171+
sa.Column("message", sa.VARCHAR(), autoincrement=False, nullable=True),
172+
sa.Column("hidden", sa.BOOLEAN(), autoincrement=False, nullable=True),
204173
sa.Column(
205174
"created",
206175
postgresql.TIMESTAMP(),
@@ -216,11 +185,40 @@ def downgrade():
216185
nullable=False,
217186
),
218187
sa.ForeignKeyConstraint(
219-
["head_commit_id"],
188+
["commit_id"],
220189
["projects_vc_commits.id"],
221-
name="fk_projects_vc_branches_head_commit_id",
190+
name="fk_projects_vc_tags_commit_id",
222191
onupdate="CASCADE",
223-
ondelete="RESTRICT",
192+
ondelete="CASCADE",
193+
),
194+
sa.ForeignKeyConstraint(
195+
["repo_id"],
196+
["projects_vc_repos.id"],
197+
name="fk_projects_vc_tags_repo_id",
198+
onupdate="CASCADE",
199+
ondelete="CASCADE",
200+
),
201+
sa.PrimaryKeyConstraint("id", name="projects_vc_tags_pkey"),
202+
sa.UniqueConstraint("name", "repo_id", name="repo_tag_uniqueness"),
203+
)
204+
205+
op.create_table(
206+
"projects_vc_heads",
207+
sa.Column("repo_id", sa.BIGINT(), autoincrement=False, nullable=False),
208+
sa.Column("head_branch_id", sa.BIGINT(), autoincrement=False, nullable=True),
209+
sa.Column(
210+
"modified",
211+
postgresql.TIMESTAMP(),
212+
server_default=sa.text("now()"),
213+
autoincrement=False,
214+
nullable=False,
215+
),
216+
sa.ForeignKeyConstraint(
217+
["head_branch_id"],
218+
["projects_vc_branches.id"],
219+
name="fk_projects_vc_heads_head_branch_id",
220+
onupdate="CASCADE",
221+
ondelete="CASCADE",
224222
),
225223
sa.ForeignKeyConstraint(
226224
["repo_id"],
@@ -229,6 +227,8 @@ def downgrade():
229227
onupdate="CASCADE",
230228
ondelete="CASCADE",
231229
),
232-
sa.PrimaryKeyConstraint("id", name="projects_vc_branches_pkey"),
233-
sa.UniqueConstraint("name", "repo_id", name="repo_branch_uniqueness"),
230+
sa.PrimaryKeyConstraint("repo_id", name="projects_vc_heads_pkey"),
231+
sa.UniqueConstraint(
232+
"head_branch_id", name="projects_vc_heads_head_branch_id_key"
233+
),
234234
)

0 commit comments

Comments
 (0)