Skip to content

Comments

Add tables/ORM classes for streamflow orders and results#73

Open
rod-glover wants to merge 5 commits intomasterfrom
i72-add-streaflow-orders-results
Open

Add tables/ORM classes for streamflow orders and results#73
rod-glover wants to merge 5 commits intomasterfrom
i72-add-streaflow-orders-results

Conversation

@rod-glover
Copy link
Contributor

@rod-glover rod-glover commented Aug 25, 2018

Resolves #72

Tasks:

  • Add ORM classes
  • Add tests for ORM classes
  • Create migration
  • Add tests for migration (existing tests cover this)

@rod-glover rod-glover requested a review from corviday September 6, 2018 23:32
@rod-glover
Copy link
Contributor Author

When reviewing, it might be worth your time to look at tests test_streamflow_workflow_new and test_streamflow_workflow_existing, which follow a happy-path sketch of the intended backend process when we eventually implement it. LMK if you see any issues here or any need for additional tests.

Otherwise this is pretty straightforward.

@corviday
Copy link
Contributor

Do you have a new ORM diagram? If so, could it be added to this PR? I personally find the diagrams really helpful, hence my continual pestering about them. :)

Copy link
Contributor

@corviday corviday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I appreciate the tests especially. I also ran the upgrade and downgrade on a dockerized database being used by an API, and verified that unsurprisingly, nothing broke.

EDIT: small issue with the downgrade I didn't catch at first, see the comment below.

)


def downgrade():
Copy link
Contributor

@corviday corviday Sep 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This downgrade does not cleanly remove the upgrade, because it does not delete the streamflow_order_statuses type. While it's unlikely to be something we need to do, we can't run the upgrade, run the downgrade, and then run the upgrade again without this error message:

sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) type "streamflow_result_statuses" already exists
 [SQL: "CREATE TYPE streamflow_result_statuses AS ENUM ('queued', 'processing', 'error', 'cancelled', 'ready', 'removed')"] (Background on this error at: http://sqlalche.me/e/f405)

Is it possible to delete the type? DROP TYPE or something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, @corviday !

Hmm. According to SQLAlchemy docs, "The table.drop() call will now emit a DROP TYPE for a table-level enumerated type."

Several things are possible here:

  1. You're running the tests with a pre-1.1.0 version of SQLAlchemy.
  2. The ENUM isn't table-level. This seems the likeliest to me, but needs some research.
  3. The ENUM is table-level, but Alembic is doing something that isn't exactly table.drop() -- hard to imagine that, but...

@nikola-rados nikola-rados force-pushed the master branch 4 times, most recently from eed3340 to fb7f9d0 Compare December 1, 2020 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants