Create table for audit
This commit is contained in:
parent
c9e1acbecb
commit
10e9b638ea
1 changed files with 46 additions and 0 deletions
46
html/admin/sql/patch/ac-upgrade12.sql
Normal file
46
html/admin/sql/patch/ac-upgrade12.sql
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
begin;
|
||||
-- Table: audit_connect
|
||||
|
||||
-- DROP TABLE audit_connect;
|
||||
|
||||
CREATE TABLE audit_connect
|
||||
(
|
||||
ac_id serial NOT NULL,
|
||||
ac_user text,
|
||||
ac_date timestamp without time zone DEFAULT now(),
|
||||
ac_ip text,
|
||||
ac_state text,
|
||||
ac_module text,
|
||||
ac_url text,
|
||||
CONSTRAINT audit_connect_pkey PRIMARY KEY (ac_id),
|
||||
CONSTRAINT valid_state CHECK (ac_state = 'FAIL'::text OR ac_state = 'SUCCESS'::text)
|
||||
);
|
||||
|
||||
CREATE OR REPLACE FUNCTION limit_user()
|
||||
RETURNS trigger AS
|
||||
$BODY$
|
||||
|
||||
begin
|
||||
NEW.ac_user := substring(NEW.ac_user from 1 for 80);
|
||||
return NEW;
|
||||
end; $BODY$
|
||||
LANGUAGE 'plpgsql' ;
|
||||
|
||||
CREATE TRIGGER limit_user_trg
|
||||
BEFORE INSERT OR UPDATE
|
||||
ON audit_connect
|
||||
FOR EACH ROW
|
||||
EXECUTE PROCEDURE limit_user();
|
||||
|
||||
|
||||
-- Index: audit_connect_ac_user
|
||||
|
||||
-- DROP INDEX audit_connect_ac_user;
|
||||
|
||||
CREATE INDEX audit_connect_ac_user
|
||||
ON audit_connect
|
||||
USING btree
|
||||
(ac_user);
|
||||
|
||||
update version set val=13;
|
||||
commit;
|
||||
Loading…
Add table
Add a link
Reference in a new issue