-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(PC-32747)[API] feat: fix schema typing and set startDatetime and end…
…Datetime not null on collective stock
- Loading branch information
1 parent
2aac204
commit 470dbef
Showing
8 changed files
with
121 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
f8588023c126 (pre) (head) | ||
b18478ab2ea8 (post) (head) | ||
a8d2c442cc67 (post) (head) |
23 changes: 23 additions & 0 deletions
23
...444a_add_not_null_constraint_on_collective_stock_startDatetime_endDatetime_step_3_of_4.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
""" | ||
Add NOT NULL constraint on "collective_stock.startDatetime" and "collective_stock.endDatetime" (step 3 of 4) | ||
""" | ||
|
||
from alembic import op | ||
|
||
|
||
# pre/post deployment: post | ||
# revision identifiers, used by Alembic. | ||
revision = "4302137d444a" | ||
down_revision = "89d6c28597ef" | ||
branch_labels: tuple[str] | None = None | ||
depends_on: list[str] | None = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.alter_column("collective_stock", "startDatetime", nullable=False) | ||
op.alter_column("collective_stock", "endDatetime", nullable=False) | ||
|
||
|
||
def downgrade() -> None: | ||
op.alter_column("collective_stock", "startDatetime", nullable=True) | ||
op.alter_column("collective_stock", "endDatetime", nullable=True) |
30 changes: 30 additions & 0 deletions
30
...97ef_add_not_null_constraint_on_collective_stock_startDatetime_endDatetime_step_2_of_4.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
Add NOT NULL constraint on "collective_stock.startDatetime" and "collective_stock.endDatetime" (step 2 of 4) | ||
""" | ||
|
||
from alembic import op | ||
|
||
from pcapi import settings | ||
|
||
# pre/post deployment: post | ||
# revision identifiers, used by Alembic. | ||
revision = "89d6c28597ef" | ||
down_revision = "a09ff41c9e94" | ||
branch_labels: tuple[str] | None = None | ||
depends_on: list[str] | None = None | ||
|
||
|
||
def upgrade() -> None: | ||
with op.get_context().autocommit_block(): | ||
op.execute("SET SESSION statement_timeout = '300s'") | ||
op.execute( | ||
'ALTER TABLE "collective_stock" VALIDATE CONSTRAINT "collective_stock_startDatetime_not_null_constraint"' | ||
) | ||
op.execute( | ||
'ALTER TABLE "collective_stock" VALIDATE CONSTRAINT "collective_stock_endDatetime_not_null_constraint"' | ||
) | ||
op.execute(f"SET SESSION statement_timeout={settings.DATABASE_STATEMENT_TIMEOUT}") | ||
|
||
|
||
def downgrade() -> None: | ||
pass |
33 changes: 33 additions & 0 deletions
33
...9e94_add_not_null_constraint_on_collective_stock_startDatetime_endDatetime_step_1_of_4.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" | ||
Add NOT NULL constraint on "collective_stock.startDatetime" and "collective_stock.endDatetime" (step 1 of 4) | ||
""" | ||
|
||
from alembic import op | ||
|
||
|
||
# pre/post deployment: post | ||
# revision identifiers, used by Alembic. | ||
revision = "a09ff41c9e94" | ||
down_revision = "b18478ab2ea8" | ||
branch_labels: tuple[str] | None = None | ||
depends_on: list[str] | None = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.execute( | ||
""" | ||
ALTER TABLE "collective_stock" DROP CONSTRAINT IF EXISTS "collective_stock_startDatetime_not_null_constraint"; | ||
ALTER TABLE "collective_stock" ADD CONSTRAINT "collective_stock_startDatetime_not_null_constraint" CHECK ("startDatetime" IS NOT NULL) NOT VALID; | ||
""" | ||
) | ||
op.execute( | ||
""" | ||
ALTER TABLE "collective_stock" DROP CONSTRAINT IF EXISTS "collective_stock_endDatetime_not_null_constraint"; | ||
ALTER TABLE "collective_stock" ADD CONSTRAINT "collective_stock_endDatetime_not_null_constraint" CHECK ("endDatetime" IS NOT NULL) NOT VALID; | ||
""" | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_constraint("collective_stock_startDatetime_not_null_constraint", table_name="collective_stock") | ||
op.drop_constraint("collective_stock_endDatetime_not_null_constraint", table_name="collective_stock") |
27 changes: 27 additions & 0 deletions
27
...cc67_add_not_null_constraint_on_collective_stock_startDatetime_endDatetime_step_4_of_4.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" | ||
Add NOT NULL constraint on "collective_stock.startDatetime" and "collective_stock.endDatetime" (step 4 of 4) | ||
""" | ||
|
||
from alembic import op | ||
|
||
|
||
# pre/post deployment: post | ||
# revision identifiers, used by Alembic. | ||
revision = "a8d2c442cc67" | ||
down_revision = "4302137d444a" | ||
branch_labels: tuple[str] | None = None | ||
depends_on: list[str] | None = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.drop_constraint("collective_stock_startDatetime_not_null_constraint", table_name="collective_stock") | ||
op.drop_constraint("collective_stock_endDatetime_not_null_constraint", table_name="collective_stock") | ||
|
||
|
||
def downgrade() -> None: | ||
op.execute( | ||
"""ALTER TABLE "collective_stock" ADD CONSTRAINT "collective_stock_startDatetime_not_null_constraint" CHECK ("startDatetime" IS NOT NULL) NOT VALID""" | ||
) | ||
op.execute( | ||
"""ALTER TABLE "collective_stock" ADD CONSTRAINT "collective_stock_endDatetime_not_null_constraint" CHECK ("endDatetime" IS NOT NULL) NOT VALID""" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters