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

[109] Fix: Cannot run a project if it does not have any DB migration #114

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

carryall
Copy link
Collaborator

@carryall carryall commented Sep 29, 2023

Resolve #109

What happened 👀

  • Check if there's any migration file before perform the database migration
  • Update Goose version to 3.15

Insight 📝

N/A

Proof Of Work 📹

After generating the app, install the dependencies and run make dev

Before: the app crashed because there was NO migration file to run

Screen.Recording.2566-09-29.at.17.47.12.mov

After: the app is runnable with the message tells there's no migration file

Screen.Recording.2566-09-29.at.17.38.18.mov

The health API works! 🎉
Screenshot 2566-09-29 at 17 55 32

@carryall carryall self-assigned this Sep 29, 2023
@carryall carryall marked this pull request as ready for review September 29, 2023 11:11
log.Fatalf("Failed to migrate database: %v", err)
}

log.Println("Migrated database successfully.")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
log.Println("Migrated database successfully.")
log.Println("Database migrated successfully.")

😇

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, changed in 4611bd3

Comment on lines 16 to 19
ifneq ("$(wildcard $(database/migrations/.keep))","")
goose -dir database/migrations -table "migration_versions" postgres "$(DATABASE_URL)" up
else
$(info NO migration files to run)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ifneq ("$(wildcard $(database/migrations/.keep))","")
goose -dir database/migrations -table "migration_versions" postgres "$(DATABASE_URL)" up
else
$(info NO migration files to run)
ifeq ("$(wildcard $(database/migrations/.keep))","")
$(info NO migration files to run)
else
goose -dir database/migrations -table "migration_versions" postgres "$(DATABASE_URL)" up

Not sure if that work, but can we use an ifeq so we don't need to process the negative form (if NOT X do A else B vs if X do B else A`)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It works so changed in 1183eb4 🙌🏼

@Nihisil Nihisil removed their request for review October 3, 2024 01:49
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.

Fix: Cannot run a project if it does not have any DB migration
2 participants