2024-12-13 14:30:08 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
servicename="$REPO_NAME"
|
|
|
|
pw_developmentdatabase="wnmhOttjA0wCiR9hVoG7jjrf90SxWvAV"
|
2024-12-13 15:37:51 -05:00
|
|
|
connnectionstr="Host=localhost;Database=$${servicename}_dev;Username=$${servicename};Password=$${pw_developmentdatabase};IncludeErrorDetail=true;"
|
2024-12-13 14:30:08 -05:00
|
|
|
|
2024-12-13 15:37:51 -05:00
|
|
|
case "$$1" in
|
2024-12-13 14:30:08 -05:00
|
|
|
"initial")
|
2024-12-13 15:37:51 -05:00
|
|
|
sudo -u postgres psql -c "create database $${servicename}_dev;"
|
|
|
|
sudo -u postgres psql -c "create user $$servicename with encrypted password '$$pw_developmentdatabase';"
|
|
|
|
sudo -u postgres psql -c "grant all privileges on database $${servicename}_dev to $$servicename;"
|
|
|
|
sudo -u postgres psql -d "$${servicename}_dev" -c "GRANT ALL ON SCHEMA public TO $$servicename"
|
2024-12-13 16:14:48 -05:00
|
|
|
|
|
|
|
cp appsettings.sample.json appsettings.json
|
2024-12-13 16:21:36 -05:00
|
|
|
dotnet ef database update --connection "$$connnectionstr"
|
2024-12-13 14:30:08 -05:00
|
|
|
;;
|
|
|
|
|
2024-12-13 16:14:48 -05:00
|
|
|
"add-migration")
|
2024-12-13 15:37:51 -05:00
|
|
|
dotnet ef migrations add "$$2"
|
2024-12-13 16:21:36 -05:00
|
|
|
dotnet ef database update --connection "$$connnectionstr"
|
|
|
|
;;
|
2024-12-13 16:19:13 -05:00
|
|
|
|
2024-12-13 16:14:48 -05:00
|
|
|
"dbupdate")
|
2024-12-13 16:21:36 -05:00
|
|
|
dotnet ef database update --connection "$$connnectionstr"
|
|
|
|
;;
|
2024-12-13 14:30:08 -05:00
|
|
|
|
|
|
|
*)
|
2024-12-13 16:21:36 -05:00
|
|
|
echo "Unknown command '$$1', try 'initial'"
|
|
|
|
;;
|
2024-12-13 14:30:08 -05:00
|
|
|
esac
|
|
|
|
|