Skip to content

Commit

Permalink
Features/192 fix alembic filingtype already exists (#194)
Browse files Browse the repository at this point in the history
closes [#192 ](#192)

## Additions

-

## Removals

-

## Changes

-

## Testing

1.

## Screenshots


## Notes

-

## Todos

-

## Checklist

- [ ] PR has an informative and human-readable title
- [ ] Changes are limited to a single goal (no scope creep)
- [ ] Code can be automatically merged (no conflicts)
- [ ] Code follows the standards laid out in the [development
playbook](https://github.com/cfpb/development)
- [ ] Passes all existing automated tests
- [ ] Any _change_ in functionality is tested
- [ ] New functions are documented (with a description, list of inputs,
and expected output)
- [ ] Placeholder code is flagged / future todos are captured in
comments
- [ ] Visually tested in supported browsers and devices (see checklist
below 👇)
- [ ] Project documentation has been updated (including the "Unreleased"
section of the CHANGELOG)
- [ ] Reviewers requested with the [Reviewers
tool](https://help.github.com/articles/requesting-a-pull-request-review/)
:arrow_right:

## Testing checklist

### Browsers

- [ ] Chrome
- [ ] Firefox
- [ ] Safari
- [ ] Internet Explorer 8, 9, 10, and 11
- [ ] Edge
- [ ] iOS Safari
- [ ] Chrome for Android

### Accessibility

- [ ] Keyboard friendly
- [ ] Screen reader friendly

### Other

- [ ] Is useable without CSS
- [ ] Is useable without JS
- [ ] Flexible from small to large screens
- [ ] No linting errors or warnings
- [ ] JavaScript tests are passing

---------

Co-authored-by: Nargis Sultani <[email protected]>
  • Loading branch information
nargis-sultani and Nargis Sultani authored May 3, 2024
1 parent 0ddf51b commit c1c0fa4
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
Create Date: 2024-01-30 13:15:44.323900
"""

from typing import Sequence, Union

from alembic import op, context
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql


# revision identifiers, used by Alembic.
Expand All @@ -25,16 +27,17 @@ def upgrade() -> None:


def downgrade() -> None:
state = postgresql.ENUM(
"FILING_STARTED",
"FILING_INSTITUTION_APPROVED",
"FILING_IN_PROGRESS",
"FILING_COMPLETE",
name="filingstate",
create_type=False,
)
state.create(op.get_bind(), checkfirst=True)

op.add_column(
"filing",
sa.Column(
"state",
sa.Enum(
"FILING_STARTED",
"FILING_INSTITUTION_APPROVED",
"FILING_IN_PROGRESS",
"FILING_COMPLETE",
name="filingstate",
),
),
sa.Column("state", state),
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql


# revision identifiers, used by Alembic.
Expand All @@ -18,8 +19,18 @@
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None

action_type = postgresql.ENUM(
"SUBMIT",
"ACCEPT",
"SIGN",
name="useractiontype",
create_type=False,
)


def upgrade() -> None:
action_type.create(op.get_bind(), checkfirst=True)

op.create_table(
"user_action",
sa.Column("id", sa.INTEGER, autoincrement=True),
Expand All @@ -28,12 +39,7 @@ def upgrade() -> None:
sa.Column("user_email", sa.String, nullable=False),
sa.Column(
"action_type",
sa.Enum(
"SUBMIT",
"ACCEPT",
"SIGN",
name="useractiontype",
),
action_type,
),
sa.Column("timestamp", sa.DateTime(), server_default=sa.func.now(), nullable=False),
sa.PrimaryKeyConstraint("id", name="user_action_pkey"),
Expand Down Expand Up @@ -102,3 +108,4 @@ def downgrade() -> None:

op.drop_table("filing_signature")
op.drop_table("user_action")
action_type.drop(op.get_bind(), checkfirst=False)
23 changes: 16 additions & 7 deletions db_revisions/versions/4659352bd865_create_filing_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,40 @@
Create Date: 2024-01-08 14:42:44.052389
"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = "4659352bd865"
down_revision: Union[str, None] = "5a775dd75356"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None

state = postgresql.ENUM(
"FILING_STARTED",
"FILING_INSTITUTION_APPROVED",
"FILING_IN_PROGRESS",
"FILING_COMPLETE",
name="filingstate",
create_type=False,
)


def upgrade() -> None:
state.create(op.get_bind(), checkfirst=True)

op.create_table(
"filing",
sa.Column("id", sa.INTEGER, autoincrement=True),
sa.Column("filing_period", sa.String, nullable=False),
sa.Column("lei", sa.String, nullable=False),
sa.Column(
"state",
sa.Enum(
"FILING_STARTED",
"FILING_INSTITUTION_APPROVED",
"FILING_IN_PROGRESS",
"FILING_COMPLETE",
name="filingstate",
),
state,
),
sa.Column("institution_snapshot_id", sa.String, nullable=False),
sa.Column("contact_info", sa.String),
Expand All @@ -43,3 +50,5 @@ def upgrade() -> None:

def downgrade() -> None:
op.drop_table("filing")

state.drop(op.get_bind(), checkfirst=False)
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,38 @@
Create Date: 2024-01-08 13:49:42.475381
"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = "5a775dd75356"
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None

filing_type = postgresql.ENUM("ANNUAL", name="filingtype", create_type=False)


def upgrade() -> None:
filing_type.create(op.get_bind(), checkfirst=True)

op.create_table(
"filing_period",
sa.Column("code", sa.String, nullable=False),
sa.Column("description", sa.String, nullable=False),
sa.Column("start_period", sa.DateTime, nullable=False),
sa.Column("end_period", sa.DateTime, nullable=False),
sa.Column("due", sa.DateTime, nullable=False),
sa.Column("filing_type", sa.Enum("ANNUAL", name="filingtype"), server_default="ANNUAL"),
sa.Column("filing_type", filing_type, server_default="ANNUAL"),
sa.PrimaryKeyConstraint("code", name="filing_period_pkey"),
)


def downgrade() -> None:
op.drop_table("filing_period")

filing_type.drop(op.get_bind(), checkfirst=False)
29 changes: 17 additions & 12 deletions db_revisions/versions/f30c5c3c7a42_create_submission_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
Create Date: 2023-12-12 12:40:14.501180
"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql


# revision identifiers, used by Alembic.
Expand All @@ -17,24 +19,26 @@
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None

state = postgresql.ENUM(
"SUBMISSION_UPLOADED",
"VALIDATION_IN_PROGRESS",
"VALIDATION_WITH_ERRORS",
"VALIDATION_WITH_WARNINGS",
"VALIDATION_SUCCESSFUL",
"SUBMISSION_SIGNED",
name="submissionstate",
create_type=False,
)


def upgrade() -> None:
state.create(op.get_bind(), checkfirst=True)

op.create_table(
"submission",
sa.Column("id", sa.INTEGER, autoincrement=True),
sa.Column("submitter", sa.String, nullable=False),
sa.Column(
"state",
sa.Enum(
"SUBMISSION_UPLOADED",
"VALIDATION_IN_PROGRESS",
"VALIDATION_WITH_ERRORS",
"VALIDATION_WITH_WARNINGS",
"VALIDATION_SUCCESSFUL",
"SUBMISSION_SIGNED",
name="submissionstate",
),
),
sa.Column("state", state),
sa.Column("validation_ruleset_version", sa.String),
sa.Column("validation_json", sa.JSON),
sa.Column("filing", sa.Integer),
Expand All @@ -46,3 +50,4 @@ def upgrade() -> None:

def downgrade() -> None:
op.drop_table("submission")
state.drop(op.get_bind(), checkfirst=False)

0 comments on commit c1c0fa4

Please sign in to comment.