Skip to content
This repository has been archived by the owner on Mar 12, 2023. It is now read-only.

Commit

Permalink
Spec added + migrations (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
grigoriev-semyon authored Nov 8, 2022
1 parent 9198b7e commit b536043
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions design_bot/models/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class Year(str, Enum):
FOURTH = "4"
FIFTH = "1м"
SIXTH = "2м"
FIFTH_SPEC = "5"
SIXTH_SPEC = "6"


class Directions(str, Enum):
Expand Down
18 changes: 18 additions & 0 deletions migrations/versions/c54ae0974f75_spec_add.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from alembic import op
import sqlalchemy as sa


revision = 'c54ae0974f75'
down_revision = 'd124a172c3b3'
branch_labels = None
depends_on = None


def upgrade():
op.execute('ALTER TABLE "user" ALTER COLUMN year TYPE varchar(10) USING year::varchar(6);')


def downgrade():
op.execute('DELETE FROM "response" WHERE user_id IN (SELECT id FROM "user" WHERE LENGTH(year) > 6) RETURNING *')
op.execute('DELETE FROM "user" WHERE LENGTH(year) > 6')
op.execute('ALTER TABLE "user" ALTER COLUMN year TYPE varchar(6) USING year::varchar(10);')

0 comments on commit b536043

Please sign in to comment.