Update flake with postgres server

This commit is contained in:
Mysaa Java
2026-06-07 02:58:18 +02:00
parent 6de4e43f8d
commit 538231dbd4
3 changed files with 17 additions and 4 deletions
+2
View File
@@ -4,6 +4,8 @@ build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
.postgres
/db-migration.sql
### STS ###
.apt_generated
+5
View File
@@ -41,6 +41,10 @@
echo "Launching misael"
${jdk}/bin/java -jar ${misael}/misael.jar --spring.datasource.url=$MISAEL_DATABASE --spring.datasource.password=$MISAEL_PASSWORD "$@"
'';
postgres-server = pkgs.writeShellScriptBin "postgres-server" ''
mkdir -p .postgres
${pkgs.podman}/bin/podman run -e POSTGRES_USER=misael -e POSTGRES_PASSWORD=misael-dev -e POSTGRES_DB=misael --volume ./.postgres:/var/lib/postgresql -p 127.0.0.1:5432:5432 postgres:18.4 & > .postgres/postgres.log &
'';
in {
packages.${system} = {
default = self.packages.${system}.misael;
@@ -50,6 +54,7 @@
apps.${system} = {
default = self.apps.${system}.misael;
misael = { type = "app"; program = "${misael-launcher}/bin/misael"; };
postgres-server = { type = "app"; program = "${postgres-server}/bin/postgres-server"; };
};
devShells.${system} = {
@@ -2,7 +2,13 @@ alter table role_privileges drop constraint role_privileges_privileges_check;
alter table role_privileges add constraint role_privileges_privileges_check
check (privileges in ('LIST_USERS','ADD_USERS','LIST_QUIZZ','CREATE_QUIZZ','VIEW_ALL_FORMS'));
insert into role_privileges VALUES
((select id from roles where "name" = 'ADMIN'),'CREATE_QUIZZ');
insert into role_privileges VALUES
((select id from roles where "name" = 'ADMIN'),'VIEW_ALL_FORMS');
do $$
begin
if exists (select id from roles where "name" = 'ADMIN')
then
insert into role_privileges VALUES
((select id from roles where "name" = 'ADMIN'),'CREATE_QUIZZ'),
((select id from roles where "name" = 'ADMIN'),'VIEW_ALL_FORMS');
end if;
end
$$