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

feat: add manual migrations using gormigration #148

Merged
merged 3 commits into from
Oct 5, 2023
Merged

Conversation

rolznz
Copy link
Contributor

@rolznz rolznz commented Sep 27, 2023

  • initial migration (postgres and sqlite)
  • update preimage to be NULL instead of ''
  • add composite index for summing payments in budget period

also fixes preimage to be NULL by default and removes gorm model hints

Manually tested with:

  • existing DB (current release schema): sqlite
  • new DB: sqlite
  • existing DB (current release schema): postgres
  • new DB: postgres

Notes:

  • initial migrations of sqlite and postgres are generated from their respective schema dumps (PostgreSQL 16, sqlite3 3.37.2)
  • I used a simple method of checking if the database is empty or not to skip the first migration so that I did not need to alter all the lines of the dumps and accidentally break something
  • current format of migrations seem verbose and prone to accidental copy-paste errors (ID/filename). Is there a better way?

- initial migration (postgres and sqlite)
- update preimage to be NULL instead of ''
- add composite index for summing payments in budget period

also fixes preimage to be NULL by default and removes gorm model hints
Copy link
Contributor

@bumi bumi left a comment

Choose a reason for hiding this comment

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

need to test it locally, but looks good to me!

migrations/202309271618.go Outdated Show resolved Hide resolved
Copy link
Contributor

@kiwiidb kiwiidb left a comment

Choose a reason for hiding this comment

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

Some pieces could be a bit more idiomatic.

migrations/202309271616_initial_migration.go Outdated Show resolved Hide resolved
migrations/202309271616_initial_migration.go Outdated Show resolved Hide resolved
migrations/202309271616_initial_migration.go Outdated Show resolved Hide resolved
migrations/202309271617_fix_preimage_null.go Outdated Show resolved Hide resolved
migrations/202309271618_add_payment_sum_index.go Outdated Show resolved Hide resolved
migrations/README.md Outdated Show resolved Hide resolved
migrations/initial_migration_postgres.sql Show resolved Hide resolved
migrations/migrate.go Outdated Show resolved Hide resolved
@rolznz
Copy link
Contributor Author

rolznz commented Oct 3, 2023

@kiwiidb all feedback has been addressed. Thanks!

@rolznz
Copy link
Contributor Author

rolznz commented Oct 3, 2023

@bumi did you test it locally?

@kiwiidb
Copy link
Contributor

kiwiidb commented Oct 3, 2023

@bumi did you test it locally?

I have, in all the scenario's that you also mentioned.

@kiwiidb kiwiidb self-requested a review October 3, 2023 07:12
@bumi
Copy link
Contributor

bumi commented Oct 3, 2023

yep, I did and looks good to me.

@kiwiidb kiwiidb merged commit 0cca7d3 into main Oct 5, 2023
2 checks passed
@reneaaron reneaaron deleted the feat/manual-migrations branch November 2, 2023 13:23
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