Mikhail Ivanov | cd2359a | 2018-04-18 17:49:01 +0400 | [diff] [blame] | 1 | classes: |
| 2 | - system.postgresql.client |
| 3 | parameters: |
| 4 | _param: |
| 5 | pushkin_db_host: ${_param:haproxy_postgresql_bind_host} |
| 6 | pushkin_db_user: pushkin |
| 7 | pushkin_db_user_password: pushkin |
| 8 | postgresql: |
| 9 | client: |
| 10 | server: |
| 11 | server01: |
| 12 | database: |
| 13 | pushkin: |
| 14 | enabled: true |
| 15 | encoding: 'UTF8' |
| 16 | locale: 'en_US' |
| 17 | users: |
| 18 | - name: ${_param:pushkin_db_user} |
| 19 | password: ${_param:pushkin_db_user_password} |
| 20 | host: ${_param:pushkin_db_host} |
| 21 | createdb: true |
| 22 | rights: all privileges |
| 23 | init: |
| 24 | maintenance_db: pushkin |
| 25 | queries: |
| 26 | - ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO public; |
| 27 | - CREATE TABLE IF NOT EXISTS login (id int8 NOT NULL, language_id int2, PRIMARY KEY (id)); |
| 28 | - 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)); |
| 29 | - CREATE INDEX IF NOT EXISTS idx_device_login_id ON device (login_id); |
| 30 | - ALTER TABLE device DROP CONSTRAINT IF EXISTS Ref_device_to_login; |
| 31 | - 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; |
| 32 | - 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)); |
| 33 | - 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)); |
| 34 | - ALTER TABLE message_localization DROP CONSTRAINT IF EXISTS ref_message_id_to_message; |
| 35 | - 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; |
| 36 | - 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)); |
| 37 | - ALTER TABLE user_message_last_time_sent DROP CONSTRAINT IF EXISTS ref_login_id_to_login |
| 38 | - 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; |
| 39 | - ALTER TABLE user_message_last_time_sent DROP CONSTRAINT IF EXISTS ref_message_id_to_message |
| 40 | - 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; |
| 41 | - ALTER TABLE login OWNER TO ${_param:pushkin_db_user}; |
| 42 | - ALTER TABLE device OWNER TO ${_param:pushkin_db_user}; |
| 43 | - ALTER TABLE message OWNER TO ${_param:pushkin_db_user}; |
| 44 | - ALTER TABLE message_localization OWNER TO ${_param:pushkin_db_user}; |
| 45 | - ALTER TABLE user_message_last_time_sent OWNER TO ${_param:pushkin_db_user}; |
| 46 | - GRANT ALL PRIVILEGES ON TABLE login TO ${_param:pushkin_db_user}; |
| 47 | - GRANT ALL PRIVILEGES ON TABLE device TO ${_param:pushkin_db_user}; |
| 48 | - GRANT ALL PRIVILEGES ON TABLE message TO ${_param:pushkin_db_user}; |
| 49 | - GRANT ALL PRIVILEGES ON TABLE message_localization TO ${_param:pushkin_db_user}; |
| 50 | - GRANT ALL PRIVILEGES ON TABLE user_message_last_time_sent TO ${_param:pushkin_db_user}; |
| 51 | extension: |
| 52 | hstore: |
| 53 | enabled: true |
| 54 | |