_template-service/devuitls.sh

32 lines
1.0 KiB
Bash
Raw Normal View History

#!/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 15:37:51 -05:00
case "$$1" in
"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
dotnet ef database update --connection "$$connnectionstr"
;;
2024-12-13 16:14:48 -05:00
"add-migration")
2024-12-13 15:37:51 -05:00
dotnet ef migrations add "$$2"
dotnet ef database update --connection "$$connnectionstr"
;;
2024-12-13 16:19:13 -05:00
2024-12-13 16:14:48 -05:00
"dbupdate")
dotnet ef database update --connection "$$connnectionstr"
;;
*)
echo "Unknown command '$$1', try 'initial'"
;;
esac