mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-12 23:36:00 +00:00
feat(backend): seed multi project architecture (#327)
* rename manual folder to seed-manual * adjust seed structure to support multiple projects * add gitignore --------- Co-authored-by: Anton Tranelis <31516529+antontranelis@users.noreply.github.com>
This commit is contained in:
parent
62777970fc
commit
d199d47730
@ -12,12 +12,8 @@ npx directus-sync push \
|
||||
--directus-email admin@it4c.dev \
|
||||
--directus-password admin123
|
||||
|
||||
npx directus-sync seed push \
|
||||
--directus-url http://localhost:8055 \
|
||||
--directus-email admin@it4c.dev \
|
||||
--directus-password admin123
|
||||
./seed.sh
|
||||
|
||||
./directus-config/seed-manual/seed.sh
|
||||
```
|
||||
|
||||
## Pull Data from Docker to Harddrive
|
||||
@ -44,27 +40,8 @@ npx directus-sync push \
|
||||
|
||||
## Seed Data for local development
|
||||
|
||||
Seed the development data via:
|
||||
```
|
||||
npx directus-sync seed push \
|
||||
--directus-url http://localhost:8055 \
|
||||
--directus-email admin@it4c.dev \
|
||||
--directus-password admin123
|
||||
```
|
||||
In order to seed the development data, run the script `backend/seed.sh`.
|
||||
|
||||
## Seed Data - find differences
|
||||
|
||||
In order so see what changes would appear when seeding, you can execute:
|
||||
```
|
||||
npx directus-sync seed diff \
|
||||
--directus-url http://localhost:8055 \
|
||||
--directus-email admin@it4c.dev \
|
||||
--directus-password admin123
|
||||
```
|
||||
|
||||
## Manual Seed
|
||||
|
||||
In order to seed files and additional data not covered by `directus-sync` run the script `backend/directus-config/seed-manual/seed.sh`.
|
||||
|
||||
## Backup Database
|
||||
|
||||
|
||||
3
backend/directus-config/seeds/.gitignore
vendored
Normal file
3
backend/directus-config/seeds/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
*
|
||||
!development/
|
||||
!.gitignore
|
||||
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
@ -0,0 +1 @@
|
||||
UPDATE public.directus_settings SET project_logo = (SELECT id FROM directus_files WHERE filename_download = 'utopia-logo.svg');
|
||||
31
backend/seed.sh
Executable file
31
backend/seed.sh
Executable file
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
# base setup
|
||||
SCRIPT_PATH=$(realpath $0)
|
||||
SCRIPT_DIR=$(dirname $SCRIPT_PATH)
|
||||
|
||||
DIRECTUS_URL="${DIRECTUS_URL:-http://localhost:8055}"
|
||||
DIRECTUS_EMAIL="${DIRECTUS_EMAIL:-admin@it4c.dev}"
|
||||
DIRECTUS_PASSWORD="${DIRECTUS_PASSWORD:-admin123}"
|
||||
|
||||
PGPASSWORD="${PGPASSWORD:-'directus'}"
|
||||
PGUSER="${PGUSER:-'directus'}"
|
||||
PGDATABASE="${PGDATABASE:-'directus'}"
|
||||
|
||||
PROJECT_NAME="${PROJECT:-development}"
|
||||
PROJECT_FOLDER=$SCRIPT_DIR/directus-config/seeds/$PROJECT_NAME
|
||||
|
||||
|
||||
npx directus-sync seed push \
|
||||
--directus-url $DIRECTUS_URL \
|
||||
--directus-email $DIRECTUS_EMAIL \
|
||||
--directus-password $DIRECTUS_PASSWORD \
|
||||
--seed-path $PROJECT_FOLDER/directus
|
||||
|
||||
|
||||
SEED_SQL_DIR=$PROJECT_FOLDER/manual
|
||||
|
||||
# apply database updates
|
||||
for filename in $SEED_SQL_DIR/*.sql; do
|
||||
docker exec -i utopia-map-database-1 /bin/bash -c "PGPASSWORD=$PGPASSWORD psql -v ON_ERROR_STOP=1 --username $PGUSER $PGDATABASE" < $filename
|
||||
done
|
||||
Loading…
x
Reference in New Issue
Block a user