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

Setup: Staged database migration #435

Merged
merged 6 commits into from
Nov 18, 2024

Conversation

martastain
Copy link
Member

@martastain martastain commented Nov 14, 2024

This pull request changes the schema migration logic to avoid long transaction that could cause issues with larger databases.

  • Old schema.public.update.sql was split to numbered files. That reduces transaction length.
  • Introduced db_migration function to handle the database schema migration process, ensuring all migrations are applied in order.
  • Modified the main function to use db_migration and save the current database version after applying migrations.

Since all migrations should be applied in order to handle old projects import, versioning will not be used just yet. But the DB will be prepared for it.

Since setup is crucial step, we now check whether it was executed properly and prevent the server from starting when an error occurs:

image

Testing

Ensure setup finishes correctly

  • on a fresh instance
  • after container re-creation
  • after running make setup

So far, it has been tested with existing local and new cloud instances:
image

@martastain martastain linked an issue Nov 14, 2024 that may be closed by this pull request
@martastain martastain self-assigned this Nov 14, 2024
@martastain martastain changed the title Split database migration file Setup: Staged database migration Nov 14, 2024
@martastain martastain marked this pull request as draft November 14, 2024 15:04
@martastain martastain added the type: enhancement Improvement of existing functionality or minor addition label Nov 14, 2024
@martastain martastain marked this pull request as ready for review November 15, 2024 08:43
Copy link
Contributor

@BigRoy BigRoy left a comment

Choose a reason for hiding this comment

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

Not sure how to test this PR - because I'm not sure how to enforce it actually going through the migration. Did a code review, and that does look good.

@martastain martastain merged commit ece59fc into develop Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Improvement of existing functionality or minor addition
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup: Split database migration
2 participants