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

Move Canteen Static Data in Migration #251

Merged
merged 31 commits into from
Oct 9, 2023

Conversation

tobiasjungmann
Copy link
Collaborator

Moves the database initialization into the migration. The db initializer is not needed anymore. Furthermore, halve the database request can be deleted since we do not need to check whether the entry already exists in the table if the table is newly cleaned.

Logging is set to silent and only in case of errors the errors will be logged.

Copy link
Member

@CommanderStorm CommanderStorm left a comment

Choose a reason for hiding this comment

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

I have left some inline style comments, have fixed a typo and have added the migration to the migration.go

Overall, nice job

server/backend/migration/20231003000000.go Outdated Show resolved Hide resolved
server/backend/migration/20231003000000.go Outdated Show resolved Hide resolved
server/backend/migration/20231003000000.go Outdated Show resolved Hide resolved
server/backend/migration/20231003000000.go Outdated Show resolved Hide resolved
server/backend/migration/20231003000000.go Outdated Show resolved Hide resolved
server/backend/migration/20231003000000.go Outdated Show resolved Hide resolved
server/backend/migration/20231003000000.go Outdated Show resolved Hide resolved
server/backend/migration/20231003000000.go Outdated Show resolved Hide resolved
server/backend/migration/20231003000000.go Outdated Show resolved Hide resolved
server/backend/migration/20231003000000.go Outdated Show resolved Hide resolved
CommanderStorm and others added 20 commits October 4, 2023 13:51
@tobiasjungmann
Copy link
Collaborator Author

I've also altered some of the older migrations to start the server on an empty database. It will be checked whether the table exists and if not, the new table will be created. @CommanderStorm please have a look at it that we are not overriding tables on the active database.

Copy link
Member

@CommanderStorm CommanderStorm left a comment

Choose a reason for hiding this comment

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

Overall, I would have merged this, exept for the added if !tx.Migrator().HasTable(&File{}) {
Why did you add them? (don't they kind of defeat the point of a migration?)

server/backend/migration/20231003000000.go Outdated Show resolved Hide resolved
server/backend/migration/20231003000000.go Outdated Show resolved Hide resolved
server/backend/migration/20231003000000.go Outdated Show resolved Hide resolved
@tobiasjungmann
Copy link
Collaborator Author

The has table is not needed anymore, this was a relic of testing a successful migration.

server/backend/migration/20210709193000.go Outdated Show resolved Hide resolved
server/backend/migration/20230826000000.go Outdated Show resolved Hide resolved
server/backend/migration/20230904100000.go Outdated Show resolved Hide resolved
server/backend/migration/20231003000000.go Outdated Show resolved Hide resolved
server/backend/migration/20231003000000.go Outdated Show resolved Hide resolved
@CommanderStorm CommanderStorm enabled auto-merge (squash) October 9, 2023 10:35
Copy link
Member

@CommanderStorm CommanderStorm left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

@CommanderStorm CommanderStorm merged commit c9801de into main Oct 9, 2023
3 checks passed
@CommanderStorm CommanderStorm deleted the chore/canteen-static-data-migration branch October 9, 2023 10:35
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