blob: 26f8abee32cd44d6a8482d0a5d2501dca00965bb [file] [log] [blame]
Mikhail Ivanovcd2359a2018-04-18 17:49:01 +04001classes:
2 - system.postgresql.client
3parameters:
4 _param:
5 pushkin_db_host: ${_param:haproxy_postgresql_bind_host}
6 pushkin_db_user: pushkin
Mikhail Ivanovcd2359a2018-04-18 17:49:01 +04007 postgresql:
8 client:
9 server:
10 server01:
11 database:
12 pushkin:
13 enabled: true
14 encoding: 'UTF8'
15 locale: 'en_US'
16 users:
17 - name: ${_param:pushkin_db_user}
18 password: ${_param:pushkin_db_user_password}
19 host: ${_param:pushkin_db_host}
20 createdb: true
21 rights: all privileges
22 init:
23 maintenance_db: pushkin
24 queries:
25 - ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO public;
26 - CREATE TABLE IF NOT EXISTS login (id int8 NOT NULL, language_id int2, PRIMARY KEY (id));
27 - CREATE TABLE IF NOT EXISTS device (id serial NOT NULL, login_id int8 NOT NULL, platform_id int2 NOT NULL, device_token text NOT NULL, device_token_new text, application_version int4, unregistered_ts timestamp, device_id text, PRIMARY KEY(id));
28 - CREATE INDEX IF NOT EXISTS idx_device_login_id ON device (login_id);
29 - ALTER TABLE device DROP CONSTRAINT IF EXISTS Ref_device_to_login;
30 - ALTER TABLE device ADD CONSTRAINT Ref_device_to_login FOREIGN KEY (login_id) REFERENCES login(id) MATCH SIMPLE ON DELETE CASCADE ON UPDATE NO ACTION NOT DEFERRABLE;
31 - CREATE TABLE IF NOT EXISTS message (id serial NOT NULL, name text NOT NULL, cooldown_ts int8, trigger_event_id int4, screen text NOT NULL DEFAULT '', PRIMARY KEY (id), CONSTRAINT c_message_unique_name UNIQUE(name));
32 - CREATE TABLE IF NOT EXISTS message_localization (id serial NOT NULL, message_id int4 NOT NULL, language_id int2 NOT NULL, message_title text NOT NULL, message_text text NOT NULL, PRIMARY KEY(id), CONSTRAINT c_message_loc_unique_message_language UNIQUE(message_id, language_id));
33 - ALTER TABLE message_localization DROP CONSTRAINT IF EXISTS ref_message_id_to_message;
34 - ALTER TABLE message_localization ADD CONSTRAINT ref_message_id_to_message FOREIGN KEY (message_id) REFERENCES message(id) MATCH SIMPLE ON DELETE CASCADE ON UPDATE NO ACTION NOT DEFERRABLE;
35 - CREATE TABLE IF NOT EXISTS user_message_last_time_sent (id serial NOT NULL, login_id int8 NOT NULL, message_id int4 NOT NULL, last_time_sent_ts_bigint int8 NOT NULL, PRIMARY KEY (id), CONSTRAINT c_user_unique_message UNIQUE(login_id, message_id));
36 - ALTER TABLE user_message_last_time_sent DROP CONSTRAINT IF EXISTS ref_login_id_to_login
37 - ALTER TABLE user_message_last_time_sent ADD CONSTRAINT ref_login_id_to_login FOREIGN KEY (login_id) REFERENCES login(id) MATCH SIMPLE ON DELETE CASCADE ON UPDATE NO ACTION NOT DEFERRABLE;
38 - ALTER TABLE user_message_last_time_sent DROP CONSTRAINT IF EXISTS ref_message_id_to_message
39 - ALTER TABLE user_message_last_time_sent ADD CONSTRAINT ref_message_id_to_message FOREIGN KEY (message_id) REFERENCES message(id) MATCH SIMPLE ON DELETE CASCADE ON UPDATE NO ACTION NOT DEFERRABLE;
40 - ALTER TABLE login OWNER TO ${_param:pushkin_db_user};
41 - ALTER TABLE device OWNER TO ${_param:pushkin_db_user};
42 - ALTER TABLE message OWNER TO ${_param:pushkin_db_user};
43 - ALTER TABLE message_localization OWNER TO ${_param:pushkin_db_user};
44 - ALTER TABLE user_message_last_time_sent OWNER TO ${_param:pushkin_db_user};
45 - GRANT ALL PRIVILEGES ON TABLE login TO ${_param:pushkin_db_user};
46 - GRANT ALL PRIVILEGES ON TABLE device TO ${_param:pushkin_db_user};
47 - GRANT ALL PRIVILEGES ON TABLE message TO ${_param:pushkin_db_user};
48 - GRANT ALL PRIVILEGES ON TABLE message_localization TO ${_param:pushkin_db_user};
49 - GRANT ALL PRIVILEGES ON TABLE user_message_last_time_sent TO ${_param:pushkin_db_user};
50 extension:
51 hstore:
52 enabled: true
53