From efffe10bad5c5d7b5993a59fe479806c189d070c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 7 Oct 2014 15:55:43 +0200 Subject: [PATCH] Merge sql schema files When populating a database we'll create all tables regardless of what is actually required for the current use case. --- etc/schema/accounts.mysql.sql | 24 ------------------ etc/schema/mysql.sql | 14 +++++++++++ etc/schema/{accounts.pgsql.sql => pgsql.sql} | 26 ++++++++------------ etc/schema/preferences.mysql.sql | 6 ----- etc/schema/preferences.pgsql.sql | 10 -------- 5 files changed, 24 insertions(+), 56 deletions(-) delete mode 100644 etc/schema/accounts.mysql.sql create mode 100644 etc/schema/mysql.sql rename etc/schema/{accounts.pgsql.sql => pgsql.sql} (50%) delete mode 100644 etc/schema/preferences.mysql.sql delete mode 100644 etc/schema/preferences.pgsql.sql diff --git a/etc/schema/accounts.mysql.sql b/etc/schema/accounts.mysql.sql deleted file mode 100644 index 72eeee4fc..000000000 --- a/etc/schema/accounts.mysql.sql +++ /dev/null @@ -1,24 +0,0 @@ -create table account ( - `username` varchar(255) COLLATE latin1_general_ci NOT NULL, - `salt` varchar(255) NOT NULL, - `password` varchar(255) NOT NULL, - `active` tinyint(1) DEFAULT NULL, - PRIMARY KEY (`username`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -/* - * user: icingaadmin - * password: icinga - */ -INSERT INTO account ( - `username`, - `salt`, - `password`, - `active` - ) - VALUES ( - 'icingaadmin', - '57cfd5746224be4f60c25d4e8514bec35ad2d01810723a138756b285898e71b2', - '43f8e0588eb39f1a41383b48def0b1fdc45e79b8f67194cccee4453eb3f4ea13', - 1 - ); diff --git a/etc/schema/mysql.sql b/etc/schema/mysql.sql new file mode 100644 index 000000000..fcf27805b --- /dev/null +++ b/etc/schema/mysql.sql @@ -0,0 +1,14 @@ +create table account ( + `username` varchar(255) COLLATE latin1_general_ci NOT NULL, + `salt` varchar(255) NOT NULL, + `password` varchar(255) NOT NULL, + `active` tinyint(1) DEFAULT NULL, + PRIMARY KEY (`username`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +create table `preference`( + `username` VARCHAR(255) COLLATE latin1_general_ci NOT NULL, + `key` VARCHAR(100) COLLATE latin1_general_ci NOT NULL, + `value` VARCHAR(255) NOT NULL, + PRIMARY KEY (`username`, `key`) +) ENGINE=InnoDB; \ No newline at end of file diff --git a/etc/schema/accounts.pgsql.sql b/etc/schema/pgsql.sql similarity index 50% rename from etc/schema/accounts.pgsql.sql rename to etc/schema/pgsql.sql index 84ecb54e8..f83517d30 100644 --- a/etc/schema/accounts.pgsql.sql +++ b/etc/schema/pgsql.sql @@ -10,19 +10,13 @@ ALTER TABLE ONLY "account" CREATE UNIQUE INDEX username_lower_unique_idx ON "account" USING btree (lower((username)::text)); -/* - * user: icingaadmin - * password: icinga - */ -INSERT INTO "account" ( - "username", - "salt", - "password", - "active" - ) - VALUES ( - 'icingaadmin', - '57cfd5746224be4f60c25d4e8514bec35ad2d01810723a138756b285898e71b2', - '43f8e0588eb39f1a41383b48def0b1fdc45e79b8f67194cccee4453eb3f4ea13', - true - ); +create table "preference"( + "username" VARCHAR(255) NOT NULL, + "key" VARCHAR(100) NOT NULL, + "value" VARCHAR(255) NOT NULL +); + +ALTER TABLE ONLY "preference" + ADD CONSTRAINT preference_pkey PRIMARY KEY ("username", "key"); + +CREATE UNIQUE INDEX username_and_key_lower_unique_idx ON "preference" USING btree (lower((username)::text), lower((key)::text)); \ No newline at end of file diff --git a/etc/schema/preferences.mysql.sql b/etc/schema/preferences.mysql.sql deleted file mode 100644 index 5549daa3f..000000000 --- a/etc/schema/preferences.mysql.sql +++ /dev/null @@ -1,6 +0,0 @@ -create table `preference`( - `username` VARCHAR(255) COLLATE latin1_general_ci NOT NULL, - `key` VARCHAR(100) COLLATE latin1_general_ci NOT NULL, - `value` VARCHAR(255) NOT NULL, - PRIMARY KEY (`username`, `key`) -) ENGINE=InnoDB; \ No newline at end of file diff --git a/etc/schema/preferences.pgsql.sql b/etc/schema/preferences.pgsql.sql deleted file mode 100644 index 8b694f0a0..000000000 --- a/etc/schema/preferences.pgsql.sql +++ /dev/null @@ -1,10 +0,0 @@ -create table "preference"( - "username" VARCHAR(255) NOT NULL, - "key" VARCHAR(100) NOT NULL, - "value" VARCHAR(255) NOT NULL -); - -ALTER TABLE ONLY "preference" - ADD CONSTRAINT preference_pkey PRIMARY KEY ("username", "key"); - -CREATE UNIQUE INDEX username_and_key_lower_unique_idx ON "preference" USING btree (lower((username)::text), lower((key)::text)); \ No newline at end of file