Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix: Address missing constraint issue #1007

Merged
merged 2 commits into from
Aug 3, 2023
Merged

Conversation

michplunkett
Copy link
Collaborator

Fixes issue

#1005

Description of Changes

This fixes the issue we were having with trying to drop the faces_user_id_fkey in the push to main. What happened was the faces_user_id_fkey wasn't saved under a name in the previous database model. PosgreSQL will drop any attached constraints when a column is dropped (presuming there are no CASCADE effects), so I am removing the drop_constraint commands and JUST dropping the column. This will allow PostgreSQL to take care of the constraint problem for us.

Tests and linting

  • This branch is up-to-date with the develop branch.
  • pytest passes on my local development environment.
  • pre-commit passes on my local development environment.
DB migration output
:/usr/src/app$ flask db upgrade
[2023-08-03 21:48:37,989] INFO in __init__: OpenOversight startup
...
INFO  [sqlalchemy.engine.Engine] COMMIT
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 18f43ac4622f -> b38c133bed3c, add created_by and created_at columns
:/usr/src/app$ flask db downgrade
[2023-08-03 21:48:50,167] INFO in __init__: OpenOversight startup
...
INFO  [sqlalchemy.engine.Engine] COMMIT
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade b38c133bed3c -> 18f43ac4622f, add created_by and created_at columns
:/usr/src/app$ flask db upgrade
[2023-08-03 21:48:58,053] INFO in __init__: OpenOversight startup
...
INFO  [sqlalchemy.engine.Engine] COMMIT
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 18f43ac4622f -> b38c133bed3c, add created_by and created_at columns
:/usr/src/app$ 

@michplunkett michplunkett self-assigned this Aug 3, 2023
@michplunkett michplunkett changed the title Address missing constriant Hotfix: Address missing constriant Aug 3, 2023
@michplunkett michplunkett linked an issue Aug 3, 2023 that may be closed by this pull request
@michplunkett michplunkett changed the title Hotfix: Address missing constriant Hotfix: Address missing constraint issue Aug 3, 2023
Copy link
Collaborator

@AetherUnbound AetherUnbound left a comment

Choose a reason for hiding this comment

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

LGTM!

@michplunkett michplunkett merged commit 6c08a17 into develop Aug 3, 2023
2 checks passed
@michplunkett michplunkett deleted the fix_fk_issue branch August 3, 2023 23:01
@michplunkett michplunkett linked an issue Aug 3, 2023 that may be closed by this pull request
sea-kelp pushed a commit to OrcaCollective/OpenOversight that referenced this pull request Sep 25, 2023
## Fixes issue
lucyparsons#1005

## Description of Changes
This fixes the issue we were having with trying to drop the
`faces_user_id_fkey` in the push to `main`. What happened was the
`faces_user_id_fkey` wasn't saved under a name in the previous database
model. PosgreSQL will drop any attached constraints when a column is
dropped (presuming there are no `CASCADE` effects), so I am removing the
`drop_constraint` commands and JUST dropping the column. This will allow
PostgreSQL to take care of the constraint problem for us.

## Tests and linting
 - [x] This branch is up-to-date with the `develop` branch.
 - [x] `pytest` passes on my local development environment.
 - [x] `pre-commit` passes on my local development environment.

<details><summary>DB migration output</summary>

```console
:/usr/src/app$ flask db upgrade
[2023-08-03 21:48:37,989] INFO in __init__: OpenOversight startup
...
INFO  [sqlalchemy.engine.Engine] COMMIT
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 18f43ac4622f -> b38c133bed3c, add created_by and created_at columns
:/usr/src/app$ flask db downgrade
[2023-08-03 21:48:50,167] INFO in __init__: OpenOversight startup
...
INFO  [sqlalchemy.engine.Engine] COMMIT
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade b38c133bed3c -> 18f43ac4622f, add created_by and created_at columns
:/usr/src/app$ flask db upgrade
[2023-08-03 21:48:58,053] INFO in __init__: OpenOversight startup
...
INFO  [sqlalchemy.engine.Engine] COMMIT
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 18f43ac4622f -> b38c133bed3c, add created_by and created_at columns
:/usr/src/app$ 
```
</details>
sea-kelp pushed a commit to OrcaCollective/OpenOversight that referenced this pull request Sep 25, 2023
## Fixes issue
lucyparsons#1005

## Description of Changes
This fixes the issue we were having with trying to drop the
`faces_user_id_fkey` in the push to `main`. What happened was the
`faces_user_id_fkey` wasn't saved under a name in the previous database
model. PosgreSQL will drop any attached constraints when a column is
dropped (presuming there are no `CASCADE` effects), so I am removing the
`drop_constraint` commands and JUST dropping the column. This will allow
PostgreSQL to take care of the constraint problem for us.

## Tests and linting
 - [x] This branch is up-to-date with the `develop` branch.
 - [x] `pytest` passes on my local development environment.
 - [x] `pre-commit` passes on my local development environment.

<details><summary>DB migration output</summary>

```console
:/usr/src/app$ flask db upgrade
[2023-08-03 21:48:37,989] INFO in __init__: OpenOversight startup
...
INFO  [sqlalchemy.engine.Engine] COMMIT
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 18f43ac4622f -> b38c133bed3c, add created_by and created_at columns
:/usr/src/app$ flask db downgrade
[2023-08-03 21:48:50,167] INFO in __init__: OpenOversight startup
...
INFO  [sqlalchemy.engine.Engine] COMMIT
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade b38c133bed3c -> 18f43ac4622f, add created_by and created_at columns
:/usr/src/app$ flask db upgrade
[2023-08-03 21:48:58,053] INFO in __init__: OpenOversight startup
...
INFO  [sqlalchemy.engine.Engine] COMMIT
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 18f43ac4622f -> b38c133bed3c, add created_by and created_at columns
:/usr/src/app$ 
```
</details>
sea-kelp pushed a commit to OrcaCollective/OpenOversight that referenced this pull request Oct 9, 2023
## Fixes issue
lucyparsons#1005

## Description of Changes
This fixes the issue we were having with trying to drop the
`faces_user_id_fkey` in the push to `main`. What happened was the
`faces_user_id_fkey` wasn't saved under a name in the previous database
model. PosgreSQL will drop any attached constraints when a column is
dropped (presuming there are no `CASCADE` effects), so I am removing the
`drop_constraint` commands and JUST dropping the column. This will allow
PostgreSQL to take care of the constraint problem for us.

## Tests and linting
 - [x] This branch is up-to-date with the `develop` branch.
 - [x] `pytest` passes on my local development environment.
 - [x] `pre-commit` passes on my local development environment.

<details><summary>DB migration output</summary>

```console
:/usr/src/app$ flask db upgrade
[2023-08-03 21:48:37,989] INFO in __init__: OpenOversight startup
...
INFO  [sqlalchemy.engine.Engine] COMMIT
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 18f43ac4622f -> b38c133bed3c, add created_by and created_at columns
:/usr/src/app$ flask db downgrade
[2023-08-03 21:48:50,167] INFO in __init__: OpenOversight startup
...
INFO  [sqlalchemy.engine.Engine] COMMIT
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade b38c133bed3c -> 18f43ac4622f, add created_by and created_at columns
:/usr/src/app$ flask db upgrade
[2023-08-03 21:48:58,053] INFO in __init__: OpenOversight startup
...
INFO  [sqlalchemy.engine.Engine] COMMIT
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 18f43ac4622f -> b38c133bed3c, add created_by and created_at columns
:/usr/src/app$ 
```
</details>
AetherUnbound pushed a commit to OrcaCollective/OpenOversight that referenced this pull request Nov 11, 2023
## Fixes issue
lucyparsons#1005

## Description of Changes
This fixes the issue we were having with trying to drop the
`faces_user_id_fkey` in the push to `main`. What happened was the
`faces_user_id_fkey` wasn't saved under a name in the previous database
model. PosgreSQL will drop any attached constraints when a column is
dropped (presuming there are no `CASCADE` effects), so I am removing the
`drop_constraint` commands and JUST dropping the column. This will allow
PostgreSQL to take care of the constraint problem for us.

## Tests and linting
 - [x] This branch is up-to-date with the `develop` branch.
 - [x] `pytest` passes on my local development environment.
 - [x] `pre-commit` passes on my local development environment.

<details><summary>DB migration output</summary>

```console
:/usr/src/app$ flask db upgrade
[2023-08-03 21:48:37,989] INFO in __init__: OpenOversight startup
...
INFO  [sqlalchemy.engine.Engine] COMMIT
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 18f43ac4622f -> b38c133bed3c, add created_by and created_at columns
:/usr/src/app$ flask db downgrade
[2023-08-03 21:48:50,167] INFO in __init__: OpenOversight startup
...
INFO  [sqlalchemy.engine.Engine] COMMIT
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running downgrade b38c133bed3c -> 18f43ac4622f, add created_by and created_at columns
:/usr/src/app$ flask db upgrade
[2023-08-03 21:48:58,053] INFO in __init__: OpenOversight startup
...
INFO  [sqlalchemy.engine.Engine] COMMIT
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade 18f43ac4622f -> b38c133bed3c, add created_by and created_at columns
:/usr/src/app$ 
```
</details>
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.

Address Faces db issue Add created_at and created_by columns to all tables
2 participants