SQL Migration Builder - is a processor of Mustache based SQL script templates.
10K+
SQL Migration Builder - is a processor of Mustache based SQL script templates.
TDB
DIST_PATH - Path to build artifacts. Relative to /data. Default: '.dist'.ENV - A name of target build environment, like a: devel, test, production. Default: ''.EXTRA_CONFIGS - Comma-separated list of additional configuration files. Relative to /data. Default: ''.SOURCE_PATH - Path to sources. Relative to /data. Default: 'migration'.VERSION_FROM - Version from. Default: '',VERSION_TO - Version to. Default: ''.is${capitalized(ENV)}database-{$ENV}.configExamples:
isProduction: true + read database-production.configisTest: true + read database-test.configisDevel: true + read database-devel.configSo you can use something like this:
--
-- EMULATOR kind will be produced only for non-production environments
--
CREATE TYPE "public"."SERVICE_KIND" AS ENUM (
{{^isProduction}}
'EMULATOR',
{{/isProduction}}
'WEBSOCKET'
);
s, $root and $parents - refer to the properties array$root - refer root data context$parent - refer parent data contextExample:
-- database.schema.common.name = common
-- database.schema.audit.name = audit
--
-- database.user.readonly = "db_ro_user"
--
-- Here we iterate all schema as array. database.schemas - refers to array with all database.schema entries.
{{#database.schemas}}
CREATE SCHEMA "{{ name }}";
COMMENT ON SCHEMA "{{ name }}" IS '{{ desc }}';
-- Mustache doesn't allow you to refer to parent objects.
-- By the "magic" you are able to refer root data context
GRANT USAGE ON SCHEMA "{{ name }}" TO "{{$root.database.user.readonly}}";
-- Mustache doesn't allow you to refer to parent objects.
-- By the "magic" you are able to refer parent data context.
GRANT USAGE ON SCHEMA "{{ name }}" TO "{{$parent.user.readonly}}";
{{/database.schemas}}
/data - Root your database work directorydocker run --interactive --tty --rm --volume /path/to/database/workdir:/data theanurin/sqlmigrationbuilder
Content type
Image
Digest
sha256:e091049c2…
Size
29.1 MB
Last updated
almost 2 years ago
docker pull theanurin/sqlmigrationbuilder