create database docs_easyfore REMOVE THIS AND UPDATE DB NAME;
create EXTENSION "uuid-ossp";
create table binaries
(
id serial not null
constraint binaries_pkey
primary key,
uuid text default uuid_generate_v4() not null,
data text,
mimetype text,
create_dt timestamp with time zone default now() not null,
modify_dt timestamp with time zone default now() not null,
orig_file_name text,
orig_crm_id integer,
translation_data text,
translation_orig_file_name text,
translation_mimetype text
)
;
create table binaries_archives
(
id serial not null
constraint binaries_archives_pkey
primary key,
old_id integer,
uuid text,
data text,
mimetype text,
create_dt timestamp with time zone,
modify_dt timestamp with time zone,
orig_file_name text,
orig_crm_id integer
)
;
create function trg_fx_modify() returns trigger
language plpgsql
as $$
DECLARE
BEGIN
new.modify_dt := now();
INSERT INTO binaries_ARCHIVES(old_id, uuid, data, mimetype, create_dt, modify_dt, orig_file_name, orig_crm_id) VALUES (OLD.id,old.uuid,old.data,old.mimetype,old.create_dt,old.modify_dt,old.orig_file_name,old.orig_crm_id);
RETURN NEW;
END;
$$
;
Back to top