Commit graph

97 commits

Author SHA1 Message Date
Yonas Habteab
b32379a1be Make is_acknowledged a boolenum & add is_sticky_acknowledgement 2025-06-05 14:23:23 +02:00
Alvar Penning
598fc7284f
Add icingadb_version column to icingadb_instance
Store the current Icinga DB version in the icingadb_instance table to be
shown in Icinga DB Web's health view.

Fixes #962.
2025-06-02 10:22:25 +02:00
Yonas Habteab
bfca74f89b schema: Set column of bytea20 storage type to PLAIN 2025-04-04 12:16:14 +02:00
Yonas Habteab
ace85d10b4 Bump expected mysql & psql schema version to 7 & 5 2025-04-04 12:16:14 +02:00
Yonas Habteab
a0307088f6 Schema: Add missing changes for PostgreSQL 2025-04-04 12:16:14 +02:00
Yonas Habteab
179cd0380a Schema: Refine all the changes & cleanup unnecessary indices & foreign keys 2025-04-04 12:16:10 +02:00
Alvar Penning
67435d4f42 Dependency: Sync dependencies, redundancy group & their state 2025-04-04 12:12:58 +02:00
Alvar Penning
c8125ecc71 schema/mysql: move dependency upgrades into schema.sql 2025-04-04 12:12:58 +02:00
Alvar Penning
e35b6dac50 schema/mysql: add environment_id, remove duplicates
https://github.com/Icinga/icingadb/pull/795#pullrequestreview-2449103721
2025-04-04 12:12:58 +02:00
Johannes Meyer
d919eb947e mysql: Add affected_children and affects_children columns 2025-04-04 12:12:58 +02:00
Johannes Meyer
d2c3fab968 schema: add last_state_change to redundancy_group_state 2025-04-04 12:12:58 +02:00
Johannes Meyer
1303d13d1f add missing keys/fks 2025-04-04 12:12:58 +02:00
Johannes Meyer
6483ef55ec schema/mysql: Add upgrade for dependency additions 2025-04-04 12:12:58 +02:00
Alvar Penning
bd780e2886
Release Icinga DB Version 1.2.1 2024-12-18 10:45:22 +01:00
Alvar Penning
fa00ac2fa9 schema/pgsql: Drop checkcommand_argument.argument_key storage mode
During #792, the storage mode for this column got lost. After further
inspection, setting a distinct storage mode for a column of type varchar
seems unnecessary.
2024-12-17 22:18:45 +01:00
Yonas Habteab
f923d6f8db schema: Fix broken upgrade script 1.3.0
PR #792 mistakenly added a `NOT NULL` clause to a nullable columns. This
PR corrects that by dropping that clause and adding a `DEFAULT NULL`
clause, making it consistent the actual schema file.
2024-12-06 10:32:17 +00:00
Alvar Penning
091388d00b
schema: Enlarge Command Argument and Environment Key
From the beginning, the Icinga DB schema allowed 64 characters for both
the command arguments and environment variable names[0]. In particular,
this affects CheckCommand, EventCommand and NotificationCommand Icinga 2
objects.

But if a command with either an argument key or an environment variable
that is longer than 64 characters was defined in Icinga 2, Icinga DB
will try to insert it into the database and may end up crashing.
Although it may seem large enough, it is sometimes exceeded.

After evaluating that there was no technical limitation[1], the limit
was increased to 255 characters. This limit was chosen over the wider
text type as it allows indexes in the future and requires less space.

For example, the following CheckCommand was not possible before:

> object CheckCommand "icingadb-i791" {
>   import "plugin-check-command"
>   command = [ "/bin/true" ]
>   env = {
>     "THAT_ARE_64_AS_WOW_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" = "huhu"
>   }
>   arguments = {
>     "java.class.that.was.used.as.an.argument.that.was.eighty.seven.characters.long.and.broke" = {
>       value = "F"
>     }
>   }
> }

Another thing was a type difference between the MySQL and PostgreSQL
schemas. While the MySQL schema defined argument_key_override as
varchar(64), in PostgreSQL it was a citext. So it was changed to
varchar(255) in MySQL and kept as it was in PostgreSQL.

Closes #791.

[0]: 05d5e97dd5
[1]: https://github.com/Icinga/icingadb/issues/791#issuecomment-2291326687
2024-08-15 18:22:33 +02:00
Alvar Penning
27d27d4539
schema: Fix values to fit by increasing type sizes
The icon_image_alt column in both the host and service tables contains
an image alt text. However, because it is defined as a varchar(32), many
alt texts do not fit. The type has been expanded to text, as with most
free text fields.

Closes #752.

When defining a TimePeriod, the maximum length of a range value was
capped at 255 characters. This limitation has now also been removed by
switching to the Text type.

Closes #724.

While re-reading the schema, I stumbled upon some missing
properties_checksum comments that were also added.
2024-07-30 10:38:19 +02:00
Alvar Penning
f0b7aa2d38
Bump version to 1.2.0 2024-04-11 13:23:34 +02:00
Alexander A. Klimov
2681634105 Unify check attempt data type to uint32 already used somewhere
A float isn't necessary as in Icinga 2 Checkable#max_check_attempts and
check_attempt are ints. But uint8 isn't enough for e.g. 1 check/s to get
HARD after 5m (300s > 255).
2024-04-08 16:01:53 +02:00
Yonas Habteab
2a0da3dec1 Add a correct composite INDEX for the history table 2024-04-05 15:43:20 +02:00
Julian Brost
16333b114d
Merge pull request #700 from Icinga/icingadb_schema-timestamp
MySQL/MariaDB: Fix `icingadb_schema.timestamp` not being UNX time
2024-03-25 09:55:28 +01:00
Alvar Penning
34ac3867a9 PostgreSQL: get_sla_ok_percent to return decimal
The final division within the get_sla_ok_percent SQL function in its
PostgreSQL implementation silently truncated decimal places. An explicit
decimal cast resulted for this equation resulted in a decimal value.

To both verify and catch this in the future, a test with odd numbers was
added. This already succeeded for MySQL, but needed the modified schema
for PostgreSQL.

Closes #648.
2024-03-20 13:16:24 +01:00
Eric Lippmann
9b213d528b schmema/mysql/1.1.2: Fix timestamp is not UNIX time
We previously incorrectly used `CURRENT_TIMESTAMP()` instead of
`UNIX_TIMESTAMP()` so the timestamps need to be corrected.
2024-03-18 11:18:45 +01:00
Eric Lippmann
dd75a5edbc schema/mysql: Use UNIX_TIMESTAMP() instead of CURRENT_TIMESTMAP()
`CURRENT_TIMESTAMP()` an alias for `NOW()` returns the current date and
time in the format `YYYY-MM-DD hh:mm:ss` using the session time zone.
Since we are using numeric context, the value is stored in the format
`YYYYMMDDhhmmss`. But actually we want to set a (millisecond) UNIX
timestamp here, so we need to use `UNIX_TIMESTAMP()` instead.
2024-03-18 10:22:35 +01:00
Julian Brost
653f356123 Increase database schema version
The removal of the `NOT NULL` constraint on `customvar_flat`.`flat_value` makes
the schema upgrade a hard requirement for 1.1.1.
2023-08-07 13:09:01 +02:00
Julian Brost
7a2ab2dff1 Schema: merge 1.2.0.sql upgrades into 1.1.1.sql
Initially, we planed a 1.2.0 release instead of 1.1.1 so over time, both schema
upgrade files appeared. Merge them to clean up in preparation for the 1.1.1
release.

Changes were generated using these commands:

    { echo; cat schema/mysql/upgrades/1.2.0.sql } >> schema/mysql/upgrades/1.1.1.sql
    { echo; cat schema/pgsql/upgrades/1.2.0.sql } >> schema/pgsql/upgrades/1.1.1.sql
    git rm schema/mysql/upgrades/1.2.0.sql
    git rm schema/pgsql/upgrades/1.2.0.sql
2023-08-07 13:09:01 +02:00
Julian Brost
6068ab78d0 Schema: change sort order of history event type enum
This improves the resulting sort order when `ORDER BY event_time, event_type`
is used. `state_change` comes first as it can cause many of the other events
like trigger downtimes, remove acknowledgements and send notifications.
Similarly, `notification` comes last as any other event can result in a
notification. This will result in history events for scenarios like state
changes, triggers downtime, sends downtime start notification being sorted in
that order.

Apart from that, end events sort before the corresponding start events as any
ack/comment/downtime/flapping period should last for more than a millisecond,
therefore if there should be two events within the same millisecond, the end
event corresponds to the older period and is sorted first.
2023-08-04 15:56:53 +02:00
Julian Brost
de09001a0f schema/pgsql: Add missing indices to hostgroup and servicegroup 2023-08-01 16:50:59 +02:00
Johannes Meyer
f46193a372 schema/mysql: Add missing indices to hostgroup and servicegroup
fixes #615
2023-08-01 16:36:31 +02:00
Julian Brost
d4b3dec82a schema/pgsql: Add new index for customvar_flat 2023-08-01 15:57:25 +02:00
Johannes Meyer
c5272605c3 schema/mysql: Add new index for customvar_flat 2023-08-01 15:36:34 +02:00
Yonas Habteab
fa0a712bac Flatten empty custom vars of type array & map correctly 2023-06-29 13:43:33 +02:00
Alexander A. Klimov
cde27fd608 schema: notification: enlarge name and name_ci 255 -> 767 2023-05-23 15:36:17 +02:00
Yonas Habteab
81e313e2db Schema: Include environment_id as part of the history retention indices
When UPSERT and DELETE statements are executed at the same time, a
deadlock can occur if both want to get an exclusive lock on one of the
PRIMARY KEY index pages. This happens with DELETE statements when there
is no suitable index for the columns used in the WHERE clause, which is
true for our history retention queries since commit eccac78. This PR
fixes the problem by adding a suitable index for the columns used in
these queries.
2022-06-29 10:05:08 +02:00
Yonas Habteab
fa6c23d634 Make json keys and DB columns consistent 2022-06-24 16:00:11 +02:00
Yonas Habteab
9ad8f0bf3e schema: Merge all alter table statments of the same table into a single one 2022-06-08 17:00:15 +02:00
Eric Lippmann
ea6646937d Add _name suffix to columns referring to name 2022-05-31 15:15:29 +02:00
Julian Brost
5f5b3fb919
Merge pull request #482 from Icinga/feature/parameter-delimiters-check-execution-6277
Add CommandArgument#Separator
2022-05-23 13:23:51 +02:00
Alexander A. Klimov
1cacfbe7ba Add CommandArgument#Separator 2022-05-16 17:26:25 +02:00
Julian Brost
3c07730bb0 PostgreSQL: add missing retention indices 2022-05-13 17:19:03 +02:00
Eric Lippmann
77b37c3551 PostgreSQL: Support text comparsion for int/enum columns
At the moment Icinga DB Web doesn't know the column types, so it sends
SQL queries with LIKE operators for all suggestions in the search bar,
which fails for numeric and enum types on PostgreSQL. To support this,
the LIKE operator (internally translated to ~~) is overloaded. Note
that this is only a temporary solution until Icinga DB Web provides
column type support.
2022-05-13 15:02:43 +02:00
Julian Brost
d119be0da5 SLA reporting: fill new tables from history in schema migration 2022-05-13 12:04:47 +02:00
Julian Brost
b81392857a SLA reporting: add SQL stored function to calculate SLA value 2022-05-13 12:04:47 +02:00
Julian Brost
7cd6fd98ce SLA reporting: SQL schema 2022-05-11 11:44:45 +02:00
Eric Lippmann
65eece39f1 Schema: Make custom variable names case insensitive
To make custom variable searches case-insensitive by default.
2022-05-09 11:35:38 +02:00
Yonas Habteab
8b5edd7802 Schema: Adjust primary key irregularities of icon_image, notes_url & action_url tables 2022-04-08 17:03:32 +02:00
Eric Lippmann
01d9023098 Add indices for history retention 2022-03-22 15:55:04 +01:00
Alexander A. Klimov
53c0aa431f Postgres: replace ENUM DOMAINs with TYPEs
Before:

idb=# select * from icingadb_instance where responsible = 'y';
ERROR:  operator does not exist: boolenum = unknown
LINE 1: select * from icingadb_instance where responsible = 'y';
                                                          ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
idb=#

refs #136
2022-03-10 17:07:06 +01:00
Alexander A. Klimov
2cf4529cc0 Postgres: use case-insensitive CITEXT columns
not to require web to LOWER().

refs #136
2022-03-10 17:04:22 +01:00