|
| 1 | +"""drop projects_version_control |
| 2 | +
|
| 3 | +Revision ID: 061607911a22 |
| 4 | +Revises: e71ea59858f4 |
| 5 | +Create Date: 2025-02-06 19:28:49.918139+00:00 |
| 6 | +
|
| 7 | +""" |
| 8 | +import sqlalchemy as sa |
| 9 | +from alembic import op |
| 10 | +from sqlalchemy.dialects import postgresql |
| 11 | + |
| 12 | +# revision identifiers, used by Alembic. |
| 13 | +revision = "061607911a22" |
| 14 | +down_revision = "e71ea59858f4" |
| 15 | +branch_labels = None |
| 16 | +depends_on = None |
| 17 | + |
| 18 | + |
| 19 | +def upgrade(): |
| 20 | + # ### commands auto generated by Alembic - please adjust! ### |
| 21 | + op.drop_table("projects_vc_tags") |
| 22 | + op.drop_table("projects_vc_commits") |
| 23 | + op.drop_table("projects_vc_branches") |
| 24 | + op.drop_table("projects_vc_snapshots") |
| 25 | + op.drop_table("projects_vc_repos") |
| 26 | + op.drop_table("projects_vc_heads") |
| 27 | + # ### end Alembic commands ### |
| 28 | + |
| 29 | + |
| 30 | +def 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 | + ) |
| 62 | + op.create_table( |
| 63 | + "projects_vc_repos", |
| 64 | + sa.Column( |
| 65 | + "id", |
| 66 | + sa.BIGINT(), |
| 67 | + server_default=sa.text("nextval('projects_vc_repos_id_seq'::regclass)"), |
| 68 | + autoincrement=True, |
| 69 | + nullable=False, |
| 70 | + ), |
| 71 | + sa.Column("project_uuid", sa.VARCHAR(), autoincrement=False, nullable=False), |
| 72 | + sa.Column("project_checksum", sa.VARCHAR(), autoincrement=False, nullable=True), |
| 73 | + sa.Column( |
| 74 | + "created", |
| 75 | + postgresql.TIMESTAMP(), |
| 76 | + server_default=sa.text("now()"), |
| 77 | + autoincrement=False, |
| 78 | + nullable=False, |
| 79 | + ), |
| 80 | + sa.Column( |
| 81 | + "modified", |
| 82 | + postgresql.TIMESTAMP(), |
| 83 | + server_default=sa.text("now()"), |
| 84 | + autoincrement=False, |
| 85 | + nullable=False, |
| 86 | + ), |
| 87 | + sa.ForeignKeyConstraint( |
| 88 | + ["project_uuid"], |
| 89 | + ["projects.uuid"], |
| 90 | + name="fk_projects_vc_repos_project_uuid", |
| 91 | + onupdate="CASCADE", |
| 92 | + ondelete="CASCADE", |
| 93 | + ), |
| 94 | + sa.PrimaryKeyConstraint("id", name="projects_vc_repos_pkey"), |
| 95 | + sa.UniqueConstraint("project_uuid", name="projects_vc_repos_project_uuid_key"), |
| 96 | + postgresql_ignore_search_path=False, |
| 97 | + ) |
| 98 | + op.create_table( |
| 99 | + "projects_vc_snapshots", |
| 100 | + sa.Column("checksum", sa.VARCHAR(), autoincrement=False, nullable=False), |
| 101 | + sa.Column( |
| 102 | + "content", |
| 103 | + postgresql.JSONB(astext_type=sa.Text()), |
| 104 | + server_default=sa.text("'{}'::jsonb"), |
| 105 | + autoincrement=False, |
| 106 | + nullable=False, |
| 107 | + ), |
| 108 | + sa.PrimaryKeyConstraint("checksum", name="projects_vc_snapshots_pkey"), |
| 109 | + postgresql_ignore_search_path=False, |
| 110 | + ) |
| 111 | + op.create_table( |
| 112 | + "projects_vc_branches", |
| 113 | + sa.Column("id", sa.BIGINT(), autoincrement=True, nullable=False), |
| 114 | + 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 | + ), |
| 124 | + sa.Column( |
| 125 | + "modified", |
| 126 | + postgresql.TIMESTAMP(), |
| 127 | + server_default=sa.text("now()"), |
| 128 | + autoincrement=False, |
| 129 | + nullable=False, |
| 130 | + ), |
| 131 | + sa.ForeignKeyConstraint( |
| 132 | + ["head_commit_id"], |
| 133 | + ["projects_vc_commits.id"], |
| 134 | + name="fk_projects_vc_branches_head_commit_id", |
| 135 | + onupdate="CASCADE", |
| 136 | + ondelete="RESTRICT", |
| 137 | + ), |
| 138 | + sa.ForeignKeyConstraint( |
| 139 | + ["repo_id"], |
| 140 | + ["projects_vc_repos.id"], |
| 141 | + name="projects_vc_branches_repo_id", |
| 142 | + onupdate="CASCADE", |
| 143 | + ondelete="CASCADE", |
| 144 | + ), |
| 145 | + sa.PrimaryKeyConstraint("id", name="projects_vc_branches_pkey"), |
| 146 | + sa.UniqueConstraint("name", "repo_id", name="repo_branch_uniqueness"), |
| 147 | + ) |
| 148 | + op.create_table( |
| 149 | + "projects_vc_commits", |
| 150 | + sa.Column( |
| 151 | + "id", |
| 152 | + sa.BIGINT(), |
| 153 | + server_default=sa.text("nextval('projects_vc_commits_id_seq'::regclass)"), |
| 154 | + autoincrement=True, |
| 155 | + nullable=False, |
| 156 | + ), |
| 157 | + sa.Column("repo_id", sa.BIGINT(), autoincrement=False, nullable=False), |
| 158 | + sa.Column("parent_commit_id", sa.BIGINT(), autoincrement=False, nullable=True), |
| 159 | + sa.Column( |
| 160 | + "snapshot_checksum", sa.VARCHAR(), autoincrement=False, nullable=False |
| 161 | + ), |
| 162 | + sa.Column("message", sa.VARCHAR(), autoincrement=False, nullable=True), |
| 163 | + sa.Column( |
| 164 | + "created", |
| 165 | + postgresql.TIMESTAMP(), |
| 166 | + server_default=sa.text("now()"), |
| 167 | + autoincrement=False, |
| 168 | + nullable=False, |
| 169 | + ), |
| 170 | + sa.ForeignKeyConstraint( |
| 171 | + ["parent_commit_id"], |
| 172 | + ["projects_vc_commits.id"], |
| 173 | + name="fk_projects_vc_commits_parent_commit_id", |
| 174 | + onupdate="CASCADE", |
| 175 | + ), |
| 176 | + sa.ForeignKeyConstraint( |
| 177 | + ["repo_id"], |
| 178 | + ["projects_vc_repos.id"], |
| 179 | + name="fk_projects_vc_commits_repo_id", |
| 180 | + onupdate="CASCADE", |
| 181 | + ondelete="CASCADE", |
| 182 | + ), |
| 183 | + sa.ForeignKeyConstraint( |
| 184 | + ["snapshot_checksum"], |
| 185 | + ["projects_vc_snapshots.checksum"], |
| 186 | + name="fk_projects_vc_commits_snapshot_checksum", |
| 187 | + onupdate="CASCADE", |
| 188 | + ondelete="RESTRICT", |
| 189 | + ), |
| 190 | + sa.PrimaryKeyConstraint("id", name="projects_vc_commits_pkey"), |
| 191 | + postgresql_ignore_search_path=False, |
| 192 | + ) |
| 193 | + op.create_table( |
| 194 | + "projects_vc_tags", |
| 195 | + sa.Column("id", sa.BIGINT(), autoincrement=True, nullable=False), |
| 196 | + sa.Column("repo_id", sa.BIGINT(), autoincrement=False, nullable=False), |
| 197 | + sa.Column("commit_id", sa.BIGINT(), autoincrement=False, nullable=False), |
| 198 | + sa.Column("name", sa.VARCHAR(), autoincrement=False, nullable=True), |
| 199 | + sa.Column("message", sa.VARCHAR(), autoincrement=False, nullable=True), |
| 200 | + sa.Column("hidden", sa.BOOLEAN(), autoincrement=False, nullable=True), |
| 201 | + sa.Column( |
| 202 | + "created", |
| 203 | + postgresql.TIMESTAMP(), |
| 204 | + server_default=sa.text("now()"), |
| 205 | + autoincrement=False, |
| 206 | + nullable=False, |
| 207 | + ), |
| 208 | + sa.Column( |
| 209 | + "modified", |
| 210 | + postgresql.TIMESTAMP(), |
| 211 | + server_default=sa.text("now()"), |
| 212 | + autoincrement=False, |
| 213 | + nullable=False, |
| 214 | + ), |
| 215 | + sa.ForeignKeyConstraint( |
| 216 | + ["commit_id"], |
| 217 | + ["projects_vc_commits.id"], |
| 218 | + name="fk_projects_vc_tags_commit_id", |
| 219 | + onupdate="CASCADE", |
| 220 | + ondelete="CASCADE", |
| 221 | + ), |
| 222 | + sa.ForeignKeyConstraint( |
| 223 | + ["repo_id"], |
| 224 | + ["projects_vc_repos.id"], |
| 225 | + name="fk_projects_vc_tags_repo_id", |
| 226 | + onupdate="CASCADE", |
| 227 | + ondelete="CASCADE", |
| 228 | + ), |
| 229 | + sa.PrimaryKeyConstraint("id", name="projects_vc_tags_pkey"), |
| 230 | + sa.UniqueConstraint("name", "repo_id", name="repo_tag_uniqueness"), |
| 231 | + ) |
| 232 | + # ### end Alembic commands ### |
0 commit comments