Some checks failed
/ build (map[dockerfile:./services/tasks/Dockerfile name:tasks]) (push) Failing after 1m25s
/ deploy (push) Has been skipped
/ build (map[dockerfile:./services/files/Dockerfile name:files]) (push) Failing after 1m34s
/ build (map[dockerfile:./services/app/Dockerfile name:app]) (push) Successful in 2m9s
/ build (map[dockerfile:./services/api/Dockerfile name:api]) (push) Failing after 1m42s
/ build (map[dockerfile:./services/web/Dockerfile name:web]) (push) Failing after 1m18s
/ build (map[dockerfile:./services/watchers/Dockerfile name:watchers]) (push) Failing after 1m22s
/ build (map[dockerfile:./services/hasura/Dockerfile name:hasura]) (push) Successful in 2m3s
54 lines
1.6 KiB
Markdown
54 lines
1.6 KiB
Markdown
# create init-migration from dev db
|
|
|
|
## remove all other migrations
|
|
|
|
```sh
|
|
rm -rf ./services/hasura/migrations/default/*
|
|
```
|
|
|
|
## dump
|
|
|
|
### Option 1: hasura dump api
|
|
```sh
|
|
curl -X POST http://localhost:4201/v1alpha1/pg_dump -H "Content-Type: application/json" -H "X-Hasura-Role: admin" -H "X-Hasura-Admin-Secret: admin" -d '{
|
|
"opts": ["-O", "-x", "--schema-only", "--schema", "public"],
|
|
"clean_output": true,
|
|
"source": "default"
|
|
}' --output init_migration.sql
|
|
export PGUSER=dev
|
|
export PGPASSWORD=dev
|
|
export PGDATABASE=dev
|
|
export PGHOST=localhost
|
|
export PGPORT=4204
|
|
pg_dump --data-only --inserts -t 'public.enum_*' | sed -n '/^INSERT INTO /p' >> init_migration.sql
|
|
pg_dump --data-only --inserts -t 'public.external_public_config' | sed -n '/^INSERT INTO /p' >> init_migration.sql
|
|
```
|
|
|
|
### Option 2: old school dump (doesn't seem to work when apply migration, or it was only the old enum_* part)
|
|
```sh
|
|
export PGUSER=dev
|
|
export PGPASSWORD=dev
|
|
export PGDATABASE=dev
|
|
export PGHOST=localhost
|
|
export PGPORT=4204
|
|
pg_dump -n public -s > init_migration.sql
|
|
pg_dump --data-only -t 'public.enum_*' >> init_migration.sql
|
|
pg_dump --data-only -t 'public.external_public_config' >> init_migration.sql
|
|
```
|
|
|
|
## save the dump as migration
|
|
|
|
```sh
|
|
migration_timestamp="$(date '+%s')000"
|
|
migration_dir="./services/hasura/migrations/default/${migration_timestamp}_init"
|
|
mkdir $migration_dir
|
|
touch "$migration_dir/down.sql"
|
|
mv init_migration.sql "$migration_dir/up.sql"
|
|
```
|
|
|
|
## up hasura
|
|
|
|
```sh
|
|
cd "services/hasura"
|
|
hasura migrate apply --version $migration_timestamp --skip-execution --endpoint http://localhost:4201 --admin-secret admin
|
|
```
|