zimbra-alarm/database.sql.j2

149 lines
3.7 KiB
Django/Jinja

-- DROP DATABASE {{ db_name }};
-- CREATE DATABASE {{ db_name }}
-- WITH
-- OWNER = {{ db_user }}
-- ENCODING = 'UTF8'
-- LC_COLLATE = 'en_US.utf8'
-- LC_CTYPE = 'en_US.utf8'
-- TABLESPACE = pg_default
-- CONNECTION LIMIT = -1;
CREATE SEQUENCE public.alarm_id_seq
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 2147483647
CACHE 1;
ALTER SEQUENCE public.alarm_id_seq
OWNER TO {{ db_user }};
CREATE SEQUENCE public.mail_accounts_id_seq
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 2147483647
CACHE 1;
ALTER SEQUENCE public.mail_accounts_id_seq
OWNER TO {{ db_user }};
CREATE SEQUENCE public.mail_sessions_id_seq
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 2147483647
CACHE 1;
ALTER SEQUENCE public.mail_sessions_id_seq
OWNER TO {{ db_user }};
CREATE SEQUENCE public.sprav_id_seq
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 2147483647
CACHE 1;
ALTER SEQUENCE public.sprav_id_seq
OWNER TO {{ db_user }};
CREATE SEQUENCE public.filter_id_seq
INCREMENT 1
START 1
MINVALUE 1
MAXVALUE 2147483647
CACHE 1;
ALTER SEQUENCE public.filter_id_seq
OWNER TO mail_alarm;
CREATE TABLE IF NOT EXISTS public.alarm
(
id integer NOT NULL DEFAULT nextval('alarm_id_seq'::regclass),
mail_account_id integer,
remote_ip inet,
country_code character(6) COLLATE pg_catalog."default",
last_time character varying COLLATE pg_catalog."default",
last_check_timestamp timestamp without time zone,
alarm_type integer,
alarm_action boolean,
action_timestamp timestamp without time zone,
mail_action_timestamp timestamp without time zone,
mail2_action_timestamp timestamp without time zone,
CONSTRAINT alarm_pkey PRIMARY KEY (id)
)
TABLESPACE pg_default;
ALTER TABLE public.alarm
OWNER to {{ db_user }};
CREATE TABLE IF NOT EXISTS public.mail_accounts
(
id integer NOT NULL DEFAULT nextval('mail_accounts_id_seq'::regclass),
client_name character varying(100) COLLATE pg_catalog."default" NOT NULL,
client_account character varying(100) COLLATE pg_catalog."default",
remote_ip inet,
country_code character(3) COLLATE pg_catalog."default",
CONSTRAINT mail_accounts_pkey PRIMARY KEY (id, client_name),
CONSTRAINT client_name UNIQUE (client_name)
)
TABLESPACE pg_default;
ALTER TABLE public.mail_accounts
OWNER to {{ db_user }};
CREATE TABLE IF NOT EXISTS public.mail_sessions
(
id integer NOT NULL DEFAULT nextval('mail_sessions_id_seq'::regclass),
mail_account_id integer,
remote_ip inet,
sessions_count integer,
country_code character(3) COLLATE pg_catalog."default",
last_time character varying COLLATE pg_catalog."default",
last_check_timestamp timestamp without time zone,
mail_reason character varying COLLATE pg_catalog."default",
CONSTRAINT mail_sessions_pkey PRIMARY KEY (id)
)
TABLESPACE pg_default;
ALTER TABLE public.mail_sessions
OWNER to {{ db_user }};
CREATE TABLE IF NOT EXISTS public.sprav
(
id integer NOT NULL DEFAULT nextval('sprav_id_seq'::regclass),
name character varying COLLATE pg_catalog."default",
sprav_type character(30) COLLATE pg_catalog."default",
CONSTRAINT sprav_pkey PRIMARY KEY (id)
)
TABLESPACE pg_default;
ALTER TABLE public.sprav
OWNER to {{ db_user }};
-- DROP TABLE public.filter;
CREATE TABLE IF NOT EXISTS public.filter
(
id integer NOT NULL DEFAULT nextval('filter_id_seq'::regclass),
remote_ip inet NOT NULL,
description character varying(100) COLLATE pg_catalog."default",
CONSTRAINT filter_pkey PRIMARY KEY (id, remote_ip)
)
TABLESPACE pg_default;
ALTER TABLE public.filter
OWNER to mail_alarm;