fix(backend): register role seed (#337)

* adjust seed structure to support multiple projects

* fix gitignore

* seed the role a user has when registered properly
This commit is contained in:
Ulf Gebhardt 2025-08-26 12:53:01 +01:00 committed by GitHub
parent 9a19617906
commit 0b77d95ae4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 9 additions and 19 deletions

View File

@ -13,7 +13,6 @@ npx directus-sync push \
--directus-password admin123 --directus-password admin123
./seed.sh ./seed.sh
``` ```
## Pull Data from Docker to Harddrive ## Pull Data from Docker to Harddrive
@ -42,7 +41,6 @@ npx directus-sync push \
In order to seed the development data, run the script `backend/seed.sh`. In order to seed the development data, run the script `backend/seed.sh`.
## Backup Database ## Backup Database
Either keep a copy of the `/data/database` folder or run the following command to get an sql dump Either keep a copy of the `/data/database` folder or run the following command to get an sql dump

View File

@ -1697,7 +1697,7 @@
"permissions": null, "permissions": null,
"validation": null, "validation": null,
"presets": { "presets": {
"role": "cccbc503-ecab-4ef1-8cf9-b6ac0f2be240" "role": "REPLACEME-WITH-REGISTRATED-ROLE_UUID"
}, },
"fields": [ "fields": [
"first_name", "first_name",

View File

@ -93,7 +93,7 @@
"app_access": false, "app_access": false,
"roles": [ "roles": [
{ {
"role": "9865ace7-27fe-4d1f-be88-99ee6410fca2", "role": "role-registrated",
"sort": 1 "sort": 1
} }
], ],

View File

@ -11,7 +11,7 @@
"icon": "paragliding", "icon": "paragliding",
"description": null, "description": null,
"parent": null, "parent": null,
"_syncId": "9865ace7-27fe-4d1f-be88-99ee6410fca2" "_syncId": "role-registrated"
}, },
{ {
"name": "Editor", "name": "Editor",

View File

@ -1,12 +0,0 @@
#!/bin/sh
# base setup
SCRIPT_PATH=$(realpath $0)
SCRIPT_DIR=$(dirname $SCRIPT_PATH)
SEED_SQL_DIR=$SCRIPT_DIR/sql
# apply database updates
for filename in $SEED_SQL_DIR/*.sql; do
docker exec -i utopia-map-database-1 /bin/bash -c "PGPASSWORD=directus psql -v ON_ERROR_STOP=1 --username directus directus" < $filename
done

View File

@ -1 +0,0 @@
UPDATE public.directus_settings SET project_logo = (SELECT id FROM directus_files WHERE filename_download = 'utopia-logo.svg');

View File

@ -1,3 +1,3 @@
* /*
!development/ !development/
!.gitignore !.gitignore

View File

@ -0,0 +1,5 @@
UPDATE public.directus_permissions
SET presets = jsonb_set(presets::jsonb,'{role}', to_jsonb((SELECT id FROM public.directus_roles WHERE name = 'Registrated')), true)
WHERE policy = (SELECT id FROM public.directus_policies WHERE name = '$t:public_label')
AND collection = 'directus_users'
AND action = 'create';