@forrestjs/service-pg-schema
v5.2.2
Published
ForrestJS service helps building a small PostgreSQL Schema
Downloads
194
Maintainers
Readme
pgSchema
Facilitates the maintenance of a simple PostgreSQL schema by running queries at boot time or in case of a TDD reset event.
This service depends on pg-service.
Configuration
pgSchema.build
Default: {}
Provide configuration to the build extension.
pgSchema.seed
Default: {}
Provide configuration to the seed extension.
pgSchema.reset
Default: {}
Provide configuration to the reset extension.
Extensions
$PG_SCHEMA_BUILD
const f1 = {
target: "$PG_SCHEMA_BUILD",
handler: async ({ query, config }) => {
await query("CREATE TABLE ...");
await query("CREATE TABLE ...");
}
};
$PG_SCHEMA_SEED
const f1 = {
target: "$PG_SCHEMA_SEED",
handler: async ({ query, config }) => {
await query("INSERT INTO ... ON CONFLICT DO NOTHING");
await query("INSERT INTO ... ON CONFLICT DO NOTHING");
}
};
$PG_SCHEMA_RESET
const f1 = {
target: "$PG_SCHEMA_RESET",
handler: async ({ query, config }) => {
await query("DROP TABLE ...");
await query("DROP TABLE ...");
}
};