1717
1818
1919def upgrade ():
20- # ### commands auto generated by Alembic - please adjust! ###
20+ op .drop_table ("projects_vc_heads" )
21+ op .drop_table ("projects_vc_branches" )
2122 op .drop_table ("projects_vc_tags" )
2223 op .drop_table ("projects_vc_commits" )
23- op .drop_table ("projects_vc_branches" )
2424 op .drop_table ("projects_vc_snapshots" )
2525 op .drop_table ("projects_vc_repos" )
26- op .drop_table ("projects_vc_heads" )
27- # ### end Alembic commands ###
2826
2927
3028def downgrade ():
31- # ### commands auto generated by Alembic - please adjust! ###
32- op .create_table (
33- "projects_vc_heads" ,
34- sa .Column ("repo_id" , sa .BIGINT (), autoincrement = False , nullable = False ),
35- sa .Column ("head_branch_id" , sa .BIGINT (), autoincrement = False , nullable = True ),
36- sa .Column (
37- "modified" ,
38- postgresql .TIMESTAMP (),
39- server_default = sa .text ("now()" ),
40- autoincrement = False ,
41- nullable = False ,
42- ),
43- sa .ForeignKeyConstraint (
44- ["head_branch_id" ],
45- ["projects_vc_branches.id" ],
46- name = "fk_projects_vc_heads_head_branch_id" ,
47- onupdate = "CASCADE" ,
48- ondelete = "CASCADE" ,
49- ),
50- sa .ForeignKeyConstraint (
51- ["repo_id" ],
52- ["projects_vc_repos.id" ],
53- name = "projects_vc_branches_repo_id" ,
54- onupdate = "CASCADE" ,
55- ondelete = "CASCADE" ,
56- ),
57- sa .PrimaryKeyConstraint ("repo_id" , name = "projects_vc_heads_pkey" ),
58- sa .UniqueConstraint (
59- "head_branch_id" , name = "projects_vc_heads_head_branch_id_key"
60- ),
61- )
29+
6230 op .create_table (
6331 "projects_vc_repos" ,
6432 sa .Column (
@@ -95,6 +63,7 @@ def downgrade():
9563 sa .UniqueConstraint ("project_uuid" , name = "projects_vc_repos_project_uuid_key" ),
9664 postgresql_ignore_search_path = False ,
9765 )
66+
9867 op .create_table (
9968 "projects_vc_snapshots" ,
10069 sa .Column ("checksum" , sa .VARCHAR (), autoincrement = False , nullable = False ),
@@ -108,19 +77,11 @@ def downgrade():
10877 sa .PrimaryKeyConstraint ("checksum" , name = "projects_vc_snapshots_pkey" ),
10978 postgresql_ignore_search_path = False ,
11079 )
80+
11181 op .create_table (
112- "projects_vc_branches" ,
113- sa .Column ("id" , sa .BIGINT (), autoincrement = True , nullable = False ),
82+ "projects_vc_heads" ,
11483 sa .Column ("repo_id" , sa .BIGINT (), autoincrement = False , nullable = False ),
115- sa .Column ("head_commit_id" , sa .BIGINT (), autoincrement = False , nullable = True ),
116- sa .Column ("name" , sa .VARCHAR (), autoincrement = False , nullable = True ),
117- sa .Column (
118- "created" ,
119- postgresql .TIMESTAMP (),
120- server_default = sa .text ("now()" ),
121- autoincrement = False ,
122- nullable = False ,
123- ),
84+ sa .Column ("head_branch_id" , sa .BIGINT (), autoincrement = False , nullable = True ),
12485 sa .Column (
12586 "modified" ,
12687 postgresql .TIMESTAMP (),
@@ -129,11 +90,11 @@ def downgrade():
12990 nullable = False ,
13091 ),
13192 sa .ForeignKeyConstraint (
132- ["head_commit_id " ],
133- ["projects_vc_commits .id" ],
134- name = "fk_projects_vc_branches_head_commit_id " ,
93+ ["head_branch_id " ],
94+ ["projects_vc_branches .id" ],
95+ name = "fk_projects_vc_heads_head_branch_id " ,
13596 onupdate = "CASCADE" ,
136- ondelete = "RESTRICT " ,
97+ ondelete = "CASCADE " ,
13798 ),
13899 sa .ForeignKeyConstraint (
139100 ["repo_id" ],
@@ -142,9 +103,12 @@ def downgrade():
142103 onupdate = "CASCADE" ,
143104 ondelete = "CASCADE" ,
144105 ),
145- sa .PrimaryKeyConstraint ("id" , name = "projects_vc_branches_pkey" ),
146- sa .UniqueConstraint ("name" , "repo_id" , name = "repo_branch_uniqueness" ),
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+ ),
147110 )
111+
148112 op .create_table (
149113 "projects_vc_commits" ,
150114 sa .Column (
@@ -190,6 +154,7 @@ def downgrade():
190154 sa .PrimaryKeyConstraint ("id" , name = "projects_vc_commits_pkey" ),
191155 postgresql_ignore_search_path = False ,
192156 )
157+
193158 op .create_table (
194159 "projects_vc_tags" ,
195160 sa .Column ("id" , sa .BIGINT (), autoincrement = True , nullable = False ),
@@ -229,4 +194,41 @@ def downgrade():
229194 sa .PrimaryKeyConstraint ("id" , name = "projects_vc_tags_pkey" ),
230195 sa .UniqueConstraint ("name" , "repo_id" , name = "repo_tag_uniqueness" ),
231196 )
232- # ### end Alembic commands ###
197+
198+ op .create_table (
199+ "projects_vc_branches" ,
200+ sa .Column ("id" , sa .BIGINT (), autoincrement = True , nullable = False ),
201+ sa .Column ("repo_id" , sa .BIGINT (), autoincrement = False , nullable = False ),
202+ sa .Column ("head_commit_id" , sa .BIGINT (), autoincrement = False , nullable = True ),
203+ sa .Column ("name" , sa .VARCHAR (), autoincrement = False , nullable = True ),
204+ sa .Column (
205+ "created" ,
206+ postgresql .TIMESTAMP (),
207+ server_default = sa .text ("now()" ),
208+ autoincrement = False ,
209+ nullable = False ,
210+ ),
211+ sa .Column (
212+ "modified" ,
213+ postgresql .TIMESTAMP (),
214+ server_default = sa .text ("now()" ),
215+ autoincrement = False ,
216+ nullable = False ,
217+ ),
218+ sa .ForeignKeyConstraint (
219+ ["head_commit_id" ],
220+ ["projects_vc_commits.id" ],
221+ name = "fk_projects_vc_branches_head_commit_id" ,
222+ onupdate = "CASCADE" ,
223+ ondelete = "RESTRICT" ,
224+ ),
225+ sa .ForeignKeyConstraint (
226+ ["repo_id" ],
227+ ["projects_vc_repos.id" ],
228+ name = "projects_vc_branches_repo_id" ,
229+ onupdate = "CASCADE" ,
230+ ondelete = "CASCADE" ,
231+ ),
232+ sa .PrimaryKeyConstraint ("id" , name = "projects_vc_branches_pkey" ),
233+ sa .UniqueConstraint ("name" , "repo_id" , name = "repo_branch_uniqueness" ),
234+ )
0 commit comments