-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path04653332ed3a_add_story_test_changes.py
69 lines (58 loc) · 2.07 KB
/
04653332ed3a_add_story_test_changes.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
"""add story test changes
Revision ID: 04653332ed3a
Revises: 91e8d22078f4
Create Date: 2021-12-10 03:27:03.107768
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision = "04653332ed3a"
down_revision = "91e8d22078f4"
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"stories", sa.Column("is_test", sa.Boolean(), default=False, nullable=False)
)
op.add_column(
"story_translations_all",
sa.Column("is_test", sa.Boolean(), default=False, nullable=False),
)
op.add_column(
"story_translations_all",
sa.Column("test_feedback", mysql.TEXT(), nullable=True),
)
op.add_column(
"story_translations_all", sa.Column("test_grade", sa.Float(), nullable=True)
)
op.add_column(
"story_translations_all", sa.Column("test_result", sa.JSON(), nullable=True)
)
op.execute(
"ALTER TABLE story_translation_contents_all MODIFY COLUMN status ENUM('DEFAULT', 'ACTION_REQUIRED', 'APPROVED', 'TEST_CORRECT', 'TEST_PARTIALLY_CORRECT', 'TEST_INCORRECT') NOT NULL;"
)
active_translations_view = """
CREATE OR REPLACE VIEW story_translations
AS
SELECT * from story_translations_all
WHERE is_deleted=0;
"""
op.execute(active_translations_view)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("story_translations_all", "test_result")
op.drop_column("story_translations_all", "test_grade")
op.drop_column("story_translations_all", "test_feedback")
op.drop_column("story_translations_all", "is_test")
op.drop_column("stories", "is_test")
active_translations_view = """
CREATE OR REPLACE VIEW story_translations
AS
SELECT * from story_translations_all
WHERE is_deleted=0;
"""
op.execute(active_translations_view)
# ### end Alembic commands ###