merge graphile_worker and postgrest db
ci / build (push) Failing after 8m20s
Details
ci / build (push) Failing after 8m20s
Details
This commit is contained in:
parent
11af3dc87b
commit
b3d9035733
|
@ -8,7 +8,7 @@ if (!process.env.DATABASE_PASSWORD) throw new Error('DATABASE_PASSWORD is missin
|
|||
|
||||
async function main() {
|
||||
const dbConfig = {
|
||||
database: "postgrest",
|
||||
database: "futureporn",
|
||||
user: "postgres",
|
||||
password: process.env.DATABASE_PASSWORD,
|
||||
host: 'postgresql-primary.futureporn.svc.cluster.local',
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
-- one trigger function to rule them all @see https://worker.graphile.org/docs/sql-add-job#example-one-trigger-function-to-rule-them-all
|
||||
CREATE FUNCTION trigger_job() RETURNS trigger AS $$
|
||||
BEGIN
|
||||
PERFORM graphile_worker.add_job(TG_ARGV[0], json_build_object(
|
||||
'schema', TG_TABLE_SCHEMA,
|
||||
'table', TG_TABLE_NAME,
|
||||
'op', TG_OP,
|
||||
'id', (CASE WHEN TG_OP = 'DELETE' THEN OLD.id ELSE NEW.id END)
|
||||
));
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql VOLATILE;
|
||||
|
||||
|
||||
-- When a record is created, add a graphile_worker job to start recording
|
||||
CREATE TRIGGER record
|
||||
AFTER INSERT ON api.records
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE trigger_job('record');
|
||||
|
||||
-- When a record is updated, add a graphile_worker job to update the discord message
|
||||
CREATE TRIGGER update_discord_message
|
||||
AFTER UPDATE ON api.records
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE trigger_job('update_discord_message');
|
||||
|
||||
-- for more reference, @see https://worker.graphile.org/docs/sql-add-job#example-one-trigger-function-to-rule-them-all
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@futureporn/migrations",
|
||||
"type": "module",
|
||||
"version": "0.5.0",
|
||||
"version": "0.6.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
Loading…
Reference in New Issue