Skip to content

Commit

Permalink
Merge pull request #4841 from Icinga/introduce-schema-table
Browse files Browse the repository at this point in the history
Introduce schema table
  • Loading branch information
nilmerg authored Jun 30, 2022
2 parents ce27161 + 9cff754 commit b435e42
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
11 changes: 11 additions & 0 deletions etc/schema/mysql-upgrades/2.11.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,14 @@ ALTER TABLE `icingaweb_user_preference`
MODIFY COLUMN `username` varchar(254) COLLATE utf8mb4_unicode_ci NOT NULL,
MODIFY COLUMN `section` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
MODIFY COLUMN `name` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL;

CREATE TABLE icingaweb_schema (
id int unsigned NOT NULL AUTO_INCREMENT,
version smallint unsigned NOT NULL,
timestamp int unsigned NOT NULL,

PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

INSERT INTO icingaweb_schema (version, timestamp)
VALUES (6, UNIX_TIMESTAMP());
13 changes: 12 additions & 1 deletion etc/schema/mysql.schema.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+
# Icinga Web 2 | (c) 2014 Icinga GmbH | GPLv2+

CREATE TABLE `icingaweb_group`(
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
Expand Down Expand Up @@ -52,3 +52,14 @@ CREATE TABLE `icingaweb_rememberme`(
mtime timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

CREATE TABLE icingaweb_schema (
id int unsigned NOT NULL AUTO_INCREMENT,
version smallint unsigned NOT NULL,
timestamp int unsigned NOT NULL,

PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

INSERT INTO icingaweb_schema (version, timestamp)
VALUES (6, UNIX_TIMESTAMP());
10 changes: 10 additions & 0 deletions etc/schema/pgsql-upgrades/2.11.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CREATE TABLE "icingaweb_schema" (
"id" serial,
"version" smallint NOT NULL,
"timestamp" int NOT NULL,

CONSTRAINT pk_icingaweb_schema PRIMARY KEY ("id")
);

INSERT INTO icingaweb_schema ("version", "timestamp")
VALUES (6, extract(epoch from now()));
13 changes: 12 additions & 1 deletion etc/schema/pgsql.schema.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */
/* Icinga Web 2 | (c) 2014 Icinga GmbH | GPLv2+ */

CREATE OR REPLACE FUNCTION unix_timestamp(timestamp with time zone) RETURNS bigint AS '
SELECT EXTRACT(EPOCH FROM $1)::bigint AS result
Expand Down Expand Up @@ -117,3 +117,14 @@ ALTER TABLE ONLY "icingaweb_rememberme"
PRIMARY KEY (
"id"
);

CREATE TABLE "icingaweb_schema" (
"id" serial,
"version" smallint NOT NULL,
"timestamp" int NOT NULL,

CONSTRAINT pk_icingaweb_schema PRIMARY KEY ("id")
);

INSERT INTO icingaweb_schema (version, timestamp)
VALUES (6, extract(epoch from now()));

0 comments on commit b435e42

Please sign in to comment.