0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 08:50:57 -05:00
penpot/backend/resources/migrations/0001.main.sql
Andrey Antukh 7a5145fa37 ♻️ Big refactor of the default data model.
Introduce teams.
2020-02-17 09:49:04 +01:00

26 lines
665 B
PL/PgSQL

CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
CREATE FUNCTION update_modified_at()
RETURNS TRIGGER AS $updt$
BEGIN
NEW.modified_at := clock_timestamp();
RETURN NEW;
END;
$updt$ LANGUAGE plpgsql;
CREATE TABLE pending_to_delete (
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
type text NOT NULL,
data jsonb NOT NULL
);
CREATE FUNCTION handle_delete()
RETURNS TRIGGER AS $pagechange$
BEGIN
INSERT INTO pending_to_delete (type, data)
VALUES (TG_TABLE_NAME, row_to_json(OLD));
RETURN OLD;
END;
$pagechange$ LANGUAGE plpgsql;