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

Add migration for annotation.pk #8154

Merged
merged 1 commit into from
Sep 8, 2023
Merged

Add migration for annotation.pk #8154

merged 1 commit into from
Sep 8, 2023

Conversation

marcospri
Copy link
Member

@marcospri marcospri commented Sep 4, 2023

Generated from model changes over: #8131 and tuned to include some raw SQL queries.

Testing

  • Forward

tox -e dev --run-command 'alembic upgrade head'

dev run-test-pre: PYTHONHASHSEED='1306123296'
dev run-test: commands[0] | alembic upgrade head
2023-09-04 15:28:21 1015712 alembic.runtime.migration [INFO] Context impl PostgresqlImpl.
2023-09-04 15:28:21 1015712 alembic.runtime.migration [INFO] Will assume transactional DDL.
2023-09-04 15:28:21 1015712 alembic.runtime.migration [INFO] Running upgrade 95825c951c08 -> f064c2b2e04a, Add pk to the annotation table.
  • Backwards

tox -e dev --run-command 'alembic downgrade -1'

dev run-test-pre: PYTHONHASHSEED='2655395263'
dev run-test: commands[0] | alembic downgrade -1
2023-09-04 15:27:57 1013953 alembic.runtime.migration [INFO] Context impl PostgresqlImpl.
2023-09-04 15:27:57 1013953 alembic.runtime.migration [INFO] Will assume transactional DDL.
2023-09-04 15:27:57 1013953 alembic.runtime.migration [INFO] Running downgrade f064c2b2e04a -> 95825c951c08, Add pk to the annotation table.



def downgrade():
op.drop_constraint(op.f("uq__annotation__pk"), "annotation", type_="unique")
Copy link
Member Author

Choose a reason for hiding this comment

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

For deletion we can use alembic own syntax.


def upgrade():
op.execute(CreateSequence(Sequence("annotation_id_seq")))
op.add_column("annotation", sa.Column("pk", sa.Integer(), nullable=True))
Copy link
Member Author

Choose a reason for hiding this comment

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

Nullable column

@marcospri marcospri merged commit 98137be into main Sep 8, 2023
6 checks passed
@marcospri marcospri deleted the annotation-pk-migration branch September 8, 2023 05:50
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.

2 participants