# migration_log

migration_id: create migration_log table
timestamp: 2026-05-07 19:49:43
sql:
  CREATE TABLE IF NOT EXISTS `migration_log` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `migration_id` TEXT NOT NULL
  , `sql` TEXT NOT NULL
  , `success` INTEGER NOT NULL
  , `error` TEXT NOT NULL
  , `timestamp` DATETIME NOT NULL
  );


migration_id: create user table
timestamp: 2026-05-07 19:49:43
sql:
  CREATE TABLE IF NOT EXISTS `user` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `version` INTEGER NOT NULL
  , `login` TEXT NOT NULL
  , `email` TEXT NOT NULL
  , `name` TEXT NULL
  , `password` TEXT NULL
  , `salt` TEXT NULL
  , `rands` TEXT NULL
  , `company` TEXT NULL
  , `account_id` INTEGER NOT NULL
  , `is_admin` INTEGER NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create user table v2
timestamp: 2026-05-07 19:49:43
sql:
  CREATE TABLE IF NOT EXISTS `user` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `version` INTEGER NOT NULL
  , `login` TEXT NOT NULL
  , `email` TEXT NOT NULL
  , `name` TEXT NULL
  , `password` TEXT NULL
  , `salt` TEXT NULL
  , `rands` TEXT NULL
  , `company` TEXT NULL
  , `org_id` INTEGER NOT NULL
  , `is_admin` INTEGER NOT NULL
  , `email_verified` INTEGER NULL
  , `theme` TEXT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: copy data_source v1 to v2
timestamp: 2026-05-07 19:49:43
sql:
  INSERT INTO `user` (`password`
  , `salt`
  , `rands`
  , `company`
  , `updated`
  , `id`
  , `name`
  , `org_id`
  , `is_admin`
  , `created`
  , `version`
  , `login`
  , `email`)
  SELECT `password`
  , `salt`
  , `rands`
  , `company`
  , `updated`
  , `id`
  , `name`
  , `account_id`
  , `is_admin`
  , `created`
  , `version`
  , `login`
  , `email`
  FROM `user_v1`


migration_id: Update is_service_account column to nullable
timestamp: 2026-05-07 19:49:44
sql:
  ALTER TABLE user ADD COLUMN tmp_service_account BOOLEAN DEFAULT 0;
  UPDATE user SET tmp_service_account = is_service_account;
  ALTER TABLE user DROP COLUMN is_service_account;
  ALTER TABLE user RENAME COLUMN tmp_service_account TO is_service_account;


migration_id: Add index on user.is_service_account and user.last_seen_at
timestamp: 2026-05-07 19:49:44
sql:
  CREATE INDEX `IDX_user_is_service_account_last_seen_at` ON `user` (`is_service_account`,`last_seen_at`);


migration_id: create temp user table v1-7
timestamp: 2026-05-07 19:49:44
sql:
  CREATE TABLE IF NOT EXISTS `temp_user` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `version` INTEGER NOT NULL
  , `email` TEXT NOT NULL
  , `name` TEXT NULL
  , `role` TEXT NULL
  , `code` TEXT NOT NULL
  , `status` TEXT NOT NULL
  , `invited_by_user_id` INTEGER NULL
  , `email_sent` INTEGER NOT NULL
  , `email_sent_on` DATETIME NULL
  , `remote_addr` TEXT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create temp_user v2
timestamp: 2026-05-07 19:49:44
sql:
  CREATE TABLE IF NOT EXISTS `temp_user` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `version` INTEGER NOT NULL
  , `email` TEXT NOT NULL
  , `name` TEXT NULL
  , `role` TEXT NULL
  , `code` TEXT NOT NULL
  , `status` TEXT NOT NULL
  , `invited_by_user_id` INTEGER NULL
  , `email_sent` INTEGER NOT NULL
  , `email_sent_on` DATETIME NULL
  , `remote_addr` TEXT NULL
  , `created` INTEGER NOT NULL DEFAULT 0
  , `updated` INTEGER NOT NULL DEFAULT 0
  );


migration_id: copy temp_user v1 to v2
timestamp: 2026-05-07 19:49:44
sql:
  INSERT INTO `temp_user` (`version`
  , `role`
  , `code`
  , `status`
  , `invited_by_user_id`
  , `email_sent`
  , `email_sent_on`
  , `org_id`
  , `email`
  , `name`
  , `remote_addr`
  , `id`)
  SELECT `version`
  , `role`
  , `code`
  , `status`
  , `invited_by_user_id`
  , `email_sent`
  , `email_sent_on`
  , `org_id`
  , `email`
  , `name`
  , `remote_addr`
  , `id`
  FROM `temp_user_tmp_qwerty`


migration_id: create star table
timestamp: 2026-05-07 19:49:44
sql:
  CREATE TABLE IF NOT EXISTS `star` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `user_id` INTEGER NOT NULL
  , `dashboard_id` INTEGER NOT NULL
  );


migration_id: add index in star table on dashboard_uid, org_id and user_id columns
timestamp: 2026-05-07 19:49:44
sql:
  CREATE UNIQUE INDEX `UQE_star_user_id_dashboard_uid_org_id` ON `star` (`user_id`,`dashboard_uid`,`org_id`);


migration_id: create org table v1
timestamp: 2026-05-07 19:49:44
sql:
  CREATE TABLE IF NOT EXISTS `org` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `version` INTEGER NOT NULL
  , `name` TEXT NOT NULL
  , `address1` TEXT NULL
  , `address2` TEXT NULL
  , `city` TEXT NULL
  , `state` TEXT NULL
  , `zip_code` TEXT NULL
  , `country` TEXT NULL
  , `billing_email` TEXT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create org_user table v1
timestamp: 2026-05-07 19:49:44
sql:
  CREATE TABLE IF NOT EXISTS `org_user` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `user_id` INTEGER NOT NULL
  , `role` TEXT NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create dashboard table
timestamp: 2026-05-07 19:49:44
sql:
  CREATE TABLE IF NOT EXISTS `dashboard` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `version` INTEGER NOT NULL
  , `slug` TEXT NOT NULL
  , `title` TEXT NOT NULL
  , `data` TEXT NOT NULL
  , `account_id` INTEGER NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create dashboard_tag table
timestamp: 2026-05-07 19:49:44
sql:
  CREATE TABLE IF NOT EXISTS `dashboard_tag` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `dashboard_id` INTEGER NOT NULL
  , `term` TEXT NOT NULL
  );


migration_id: add unique index dashboard_tag.dasboard_id_term
timestamp: 2026-05-07 19:49:44
sql:
  CREATE UNIQUE INDEX `UQE_dashboard_tag_dashboard_id_term` ON `dashboard_tag` (`dashboard_id`,`term`);


migration_id: create dashboard v2
timestamp: 2026-05-07 19:49:45
sql:
  CREATE TABLE IF NOT EXISTS `dashboard` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `version` INTEGER NOT NULL
  , `slug` TEXT NOT NULL
  , `title` TEXT NOT NULL
  , `data` TEXT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: copy dashboard v1 to v2
timestamp: 2026-05-07 19:49:45
sql:
  INSERT INTO `dashboard` (`updated`
  , `id`
  , `version`
  , `slug`
  , `title`
  , `data`
  , `org_id`
  , `created`)
  SELECT `updated`
  , `id`
  , `version`
  , `slug`
  , `title`
  , `data`
  , `account_id`
  , `created`
  FROM `dashboard_v1`


migration_id: Add unique index for dashboard_org_id_title_folder_id
timestamp: 2026-05-07 19:49:45
sql:
  CREATE UNIQUE INDEX `UQE_dashboard_org_id_folder_id_title` ON `dashboard` (`org_id`,`folder_id`,`title`);


migration_id: create dashboard_provisioning
timestamp: 2026-05-07 19:49:45
sql:
  CREATE TABLE IF NOT EXISTS `dashboard_provisioning` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `dashboard_id` INTEGER NULL
  , `name` TEXT NOT NULL
  , `external_id` TEXT NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create dashboard_provisioning v2
timestamp: 2026-05-07 19:49:45
sql:
  CREATE TABLE IF NOT EXISTS `dashboard_provisioning` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `dashboard_id` INTEGER NULL
  , `name` TEXT NOT NULL
  , `external_id` TEXT NOT NULL
  , `updated` INTEGER NOT NULL DEFAULT 0
  );


migration_id: create index IDX_dashboard_provisioning_dashboard_id - v2
timestamp: 2026-05-07 19:49:45
sql:
  CREATE INDEX `IDX_dashboard_provisioning_dashboard_id` ON `dashboard_provisioning` (`dashboard_id`);


migration_id: create index IDX_dashboard_provisioning_dashboard_id_name - v2
timestamp: 2026-05-07 19:49:45
sql:
  CREATE INDEX `IDX_dashboard_provisioning_dashboard_id_name` ON `dashboard_provisioning` (`dashboard_id`,`name`);


migration_id: copy dashboard_provisioning v1 to v2
timestamp: 2026-05-07 19:49:45
sql:
  INSERT INTO `dashboard_provisioning` (`id`
  , `dashboard_id`
  , `name`
  , `external_id`)
  SELECT `id`
  , `dashboard_id`
  , `name`
  , `external_id`
  FROM `dashboard_provisioning_tmp_qwerty`


migration_id: create data_source table
timestamp: 2026-05-07 19:49:45
sql:
  CREATE TABLE IF NOT EXISTS `data_source` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `account_id` INTEGER NOT NULL
  , `version` INTEGER NOT NULL
  , `type` TEXT NOT NULL
  , `name` TEXT NOT NULL
  , `access` TEXT NOT NULL
  , `url` TEXT NOT NULL
  , `password` TEXT NULL
  , `user` TEXT NULL
  , `database` TEXT NULL
  , `basic_auth` INTEGER NOT NULL
  , `basic_auth_user` TEXT NULL
  , `basic_auth_password` TEXT NULL
  , `is_default` INTEGER NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create data_source table v2
timestamp: 2026-05-07 19:49:45
sql:
  CREATE TABLE IF NOT EXISTS `data_source` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `version` INTEGER NOT NULL
  , `type` TEXT NOT NULL
  , `name` TEXT NOT NULL
  , `access` TEXT NOT NULL
  , `url` TEXT NOT NULL
  , `password` TEXT NULL
  , `user` TEXT NULL
  , `database` TEXT NULL
  , `basic_auth` INTEGER NOT NULL
  , `basic_auth_user` TEXT NULL
  , `basic_auth_password` TEXT NULL
  , `is_default` INTEGER NOT NULL
  , `json_data` TEXT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create api_key table
timestamp: 2026-05-07 19:49:46
sql:
  CREATE TABLE IF NOT EXISTS `api_key` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `account_id` INTEGER NOT NULL
  , `name` TEXT NOT NULL
  , `key` TEXT NOT NULL
  , `role` TEXT NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create api_key table v2
timestamp: 2026-05-07 19:49:47
sql:
  CREATE TABLE IF NOT EXISTS `api_key` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `name` TEXT NOT NULL
  , `key` TEXT NOT NULL
  , `role` TEXT NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: copy api_key v1 to v2
timestamp: 2026-05-07 19:49:47
sql:
  INSERT INTO `api_key` (`role`
  , `created`
  , `updated`
  , `id`
  , `org_id`
  , `name`
  , `key`)
  SELECT `role`
  , `created`
  , `updated`
  , `id`
  , `account_id`
  , `name`
  , `key`
  FROM `api_key_v1`


migration_id: create dashboard_snapshot table v4
timestamp: 2026-05-07 19:49:47
sql:
  CREATE TABLE IF NOT EXISTS `dashboard_snapshot` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `name` TEXT NOT NULL
  , `key` TEXT NOT NULL
  , `dashboard` TEXT NOT NULL
  , `expires` DATETIME NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create dashboard_snapshot table v5 #2
timestamp: 2026-05-07 19:49:47
sql:
  CREATE TABLE IF NOT EXISTS `dashboard_snapshot` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `name` TEXT NOT NULL
  , `key` TEXT NOT NULL
  , `delete_key` TEXT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `user_id` INTEGER NOT NULL
  , `external` INTEGER NOT NULL
  , `external_url` TEXT NOT NULL
  , `dashboard` TEXT NOT NULL
  , `expires` DATETIME NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create quota table v1
timestamp: 2026-05-07 19:49:47
sql:
  CREATE TABLE IF NOT EXISTS `quota` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NULL
  , `user_id` INTEGER NULL
  , `target` TEXT NOT NULL
  , `limit` INTEGER NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create plugin_setting table
timestamp: 2026-05-07 19:49:47
sql:
  CREATE TABLE IF NOT EXISTS `plugin_setting` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NULL
  , `plugin_id` TEXT NOT NULL
  , `enabled` INTEGER NOT NULL
  , `pinned` INTEGER NOT NULL
  , `json_data` TEXT NULL
  , `secure_json_data` TEXT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create index UQE_plugin_setting_org_id_plugin_id - v1
timestamp: 2026-05-07 19:49:47
sql:
  CREATE UNIQUE INDEX `UQE_plugin_setting_org_id_plugin_id` ON `plugin_setting` (`org_id`,`plugin_id`);


migration_id: make org_id NOT NULL and DEFAULT VALUE 1
timestamp: 2026-05-07 19:49:47
sql:
  			CREATE TABLE "plugin_setting_new" (
  			"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  			"org_id" INTEGER NOT NULL DEFAULT 1,
  			"plugin_id" TEXT NOT NULL,
  			"enabled" INTEGER NOT NULL,
  			"pinned" INTEGER NOT NULL,
  			"json_data" TEXT NULL,
  			"secure_json_data" TEXT NULL,
  			"created" DATETIME NOT NULL,
  			"updated" DATETIME NOT NULL,
  			"plugin_version" TEXT NULL);
  			INSERT INTO "plugin_setting_new" SELECT
  				"id",
  				COALESCE("org_id", 1),
  				"plugin_id",
  				"enabled",
  				"pinned",
  				"json_data",
  				"secure_json_data",
  				"created",
  				"updated",
  				"plugin_version"
  			FROM "plugin_setting";
  			DROP TABLE "plugin_setting";
  			ALTER TABLE "plugin_setting_new" RENAME TO "plugin_setting";
  			CREATE UNIQUE INDEX "UQE_plugin_setting_org_id_plugin_id" ON "plugin_setting" ("org_id","plugin_id");
  		


migration_id: create session table
timestamp: 2026-05-07 19:49:47
sql:
  CREATE TABLE IF NOT EXISTS `session` (
  `key` TEXT PRIMARY KEY NOT NULL
  , `data` BLOB NOT NULL
  , `expiry` INTEGER NOT NULL
  );


migration_id: create playlist table v2
timestamp: 2026-05-07 19:49:47
sql:
  CREATE TABLE IF NOT EXISTS `playlist` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `name` TEXT NOT NULL
  , `interval` TEXT NOT NULL
  , `org_id` INTEGER NOT NULL
  );


migration_id: create playlist item table v2
timestamp: 2026-05-07 19:49:47
sql:
  CREATE TABLE IF NOT EXISTS `playlist_item` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `playlist_id` INTEGER NOT NULL
  , `type` TEXT NOT NULL
  , `value` TEXT NOT NULL
  , `title` TEXT NOT NULL
  , `order` INTEGER NOT NULL
  );


migration_id: create preferences table v3
timestamp: 2026-05-07 19:49:48
sql:
  CREATE TABLE IF NOT EXISTS `preferences` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `user_id` INTEGER NOT NULL
  , `version` INTEGER NOT NULL
  , `home_dashboard_id` INTEGER NOT NULL
  , `timezone` TEXT NOT NULL
  , `theme` TEXT NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create alert table v1
timestamp: 2026-05-07 19:49:48
sql:
  CREATE TABLE IF NOT EXISTS `alert` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `version` INTEGER NOT NULL
  , `dashboard_id` INTEGER NOT NULL
  , `panel_id` INTEGER NOT NULL
  , `org_id` INTEGER NOT NULL
  , `name` TEXT NOT NULL
  , `message` TEXT NOT NULL
  , `state` TEXT NOT NULL
  , `settings` TEXT NOT NULL
  , `frequency` INTEGER NOT NULL
  , `handler` INTEGER NOT NULL
  , `severity` TEXT NOT NULL
  , `silenced` INTEGER NOT NULL
  , `execution_error` TEXT NOT NULL
  , `eval_data` TEXT NULL
  , `eval_date` DATETIME NULL
  , `new_state_date` DATETIME NOT NULL
  , `state_changes` INTEGER NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: Create alert_rule_tag table v1
timestamp: 2026-05-07 19:49:48
sql:
  CREATE TABLE IF NOT EXISTS `alert_rule_tag` (
  `alert_id` INTEGER NOT NULL
  , `tag_id` INTEGER NOT NULL
  );


migration_id: Create alert_rule_tag table v2
timestamp: 2026-05-07 19:49:48
sql:
  CREATE TABLE IF NOT EXISTS `alert_rule_tag` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `alert_id` INTEGER NOT NULL
  , `tag_id` INTEGER NOT NULL
  );


sql: CREATE UNIQUE INDEX `UQE_alert_rule_tag_alert_id_tag_id` ON `alert_rule_tag` (`alert_id`,`tag_id`);
timestamp: 2026-05-07 19:49:48
migration_id:
  create index UQE_alert_rule_tag_alert_id_tag_id - Add unique index alert_rule_tag.alert_id_tag_id V2


migration_id: copy alert_rule_tag v1 to v2
timestamp: 2026-05-07 19:49:48
sql:
  INSERT INTO `alert_rule_tag` (`alert_id`
  , `tag_id`)
  SELECT `alert_id`
  , `tag_id`
  FROM `alert_rule_tag_v1`


migration_id: create alert_notification table v1
timestamp: 2026-05-07 19:49:48
sql:
  CREATE TABLE IF NOT EXISTS `alert_notification` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `name` TEXT NOT NULL
  , `type` TEXT NOT NULL
  , `settings` TEXT NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create notification_journal table v1
timestamp: 2026-05-07 19:49:48
sql:
  CREATE TABLE IF NOT EXISTS `alert_notification_journal` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `alert_id` INTEGER NOT NULL
  , `notifier_id` INTEGER NOT NULL
  , `sent_at` INTEGER NOT NULL
  , `success` INTEGER NOT NULL
  );


migration_id: add index notification_journal org_id & alert_id & notifier_id
timestamp: 2026-05-07 19:49:48
sql:
  CREATE INDEX `IDX_alert_notification_journal_org_id_alert_id_notifier_id` ON `alert_notification_journal` (`org_id`,`alert_id`,`notifier_id`);


migration_id: create alert_notification_state table v1
timestamp: 2026-05-07 19:49:48
sql:
  CREATE TABLE IF NOT EXISTS `alert_notification_state` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `alert_id` INTEGER NOT NULL
  , `notifier_id` INTEGER NOT NULL
  , `state` TEXT NOT NULL
  , `version` INTEGER NOT NULL
  , `updated_at` INTEGER NOT NULL
  , `alert_rule_state_updated_version` INTEGER NOT NULL
  );


migration_id: add index alert_notification_state org_id & alert_id & notifier_id
timestamp: 2026-05-07 19:49:48
sql:
  CREATE UNIQUE INDEX `UQE_alert_notification_state_org_id_alert_id_notifier_id` ON `alert_notification_state` (`org_id`,`alert_id`,`notifier_id`);


migration_id: create annotation table v5
timestamp: 2026-05-07 19:49:48
sql:
  CREATE TABLE IF NOT EXISTS `annotation` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `alert_id` INTEGER NULL
  , `user_id` INTEGER NULL
  , `dashboard_id` INTEGER NULL
  , `panel_id` INTEGER NULL
  , `category_id` INTEGER NULL
  , `type` TEXT NOT NULL
  , `title` TEXT NOT NULL
  , `text` TEXT NOT NULL
  , `metric` TEXT NULL
  , `prev_state` TEXT NOT NULL
  , `new_state` TEXT NOT NULL
  , `data` TEXT NOT NULL
  , `epoch` INTEGER NOT NULL
  );


migration_id: add index annotation 3 v3
timestamp: 2026-05-07 19:49:49
sql:
  CREATE INDEX `IDX_annotation_org_id_dashboard_id_panel_id_epoch` ON `annotation` (`org_id`,`dashboard_id`,`panel_id`,`epoch`);


migration_id: Create annotation_tag table v2
timestamp: 2026-05-07 19:49:49
sql:
  CREATE TABLE IF NOT EXISTS `annotation_tag` (
  `annotation_id` INTEGER NOT NULL
  , `tag_id` INTEGER NOT NULL
  );


migration_id: Add unique index annotation_tag.annotation_id_tag_id
timestamp: 2026-05-07 19:49:49
sql:
  CREATE UNIQUE INDEX `UQE_annotation_tag_annotation_id_tag_id` ON `annotation_tag` (`annotation_id`,`tag_id`);


migration_id: Create annotation_tag table v3
timestamp: 2026-05-07 19:49:49
sql:
  CREATE TABLE IF NOT EXISTS `annotation_tag` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `annotation_id` INTEGER NOT NULL
  , `tag_id` INTEGER NOT NULL
  );


timestamp: 2026-05-07 19:49:49
migration_id:
  create index UQE_annotation_tag_annotation_id_tag_id - Add unique index annotation_tag.annotation_id_tag_id V3

sql:
  CREATE UNIQUE INDEX `UQE_annotation_tag_annotation_id_tag_id` ON `annotation_tag` (`annotation_id`,`tag_id`);


migration_id: copy annotation_tag v2 to v3
timestamp: 2026-05-07 19:49:49
sql:
  INSERT INTO `annotation_tag` (`annotation_id`
  , `tag_id`)
  SELECT `annotation_id`
  , `tag_id`
  FROM `annotation_tag_v2`


migration_id: Add index for epoch_end
timestamp: 2026-05-07 19:49:49
sql:
  CREATE INDEX `IDX_annotation_org_id_epoch_epoch_end` ON `annotation` (`org_id`,`epoch`,`epoch_end`);


migration_id: Add index for org_id_dashboard_id_epoch_end_epoch on annotation table
timestamp: 2026-05-07 19:49:49
sql:
  CREATE INDEX `IDX_annotation_org_id_dashboard_id_epoch_end_epoch` ON `annotation` (`org_id`,`dashboard_id`,`epoch_end`,`epoch`);


migration_id: Add index for org_id_epoch_end_epoch on annotation table
timestamp: 2026-05-07 19:49:49
sql:
  CREATE INDEX `IDX_annotation_org_id_epoch_end_epoch` ON `annotation` (`org_id`,`epoch_end`,`epoch`);


migration_id: create test_data table
timestamp: 2026-05-07 19:49:49
sql:
  CREATE TABLE IF NOT EXISTS `test_data` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `metric1` TEXT NULL
  , `metric2` TEXT NULL
  , `value_big_int` INTEGER NULL
  , `value_double` REAL NULL
  , `value_float` REAL NULL
  , `value_int` INTEGER NULL
  , `time_epoch` INTEGER NOT NULL
  , `time_date_time` DATETIME NOT NULL
  , `time_time_stamp` DATETIME NOT NULL
  );


migration_id: create dashboard_version table v1
timestamp: 2026-05-07 19:49:49
sql:
  CREATE TABLE IF NOT EXISTS `dashboard_version` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `dashboard_id` INTEGER NOT NULL
  , `parent_version` INTEGER NOT NULL
  , `restored_from` INTEGER NOT NULL
  , `version` INTEGER NOT NULL
  , `created` DATETIME NOT NULL
  , `created_by` INTEGER NOT NULL
  , `message` TEXT NOT NULL
  , `data` TEXT NOT NULL
  );


migration_id: add unique index dashboard_version.dashboard_id and dashboard_version.version
timestamp: 2026-05-07 19:49:49
sql:
  CREATE UNIQUE INDEX `UQE_dashboard_version_dashboard_id_version` ON `dashboard_version` (`dashboard_id`,`version`);


migration_id: save existing dashboard data in dashboard_version table v1
timestamp: 2026-05-07 19:49:49
sql:
  INSERT INTO dashboard_version
  (
  	dashboard_id,
  	version,
  	parent_version,
  	restored_from,
  	created,
  	created_by,
  	message,
  	data
  )
  SELECT
  	dashboard.id,
  	dashboard.version,
  	dashboard.version,
  	dashboard.version,
  	dashboard.updated,
  	COALESCE(dashboard.updated_by, -1),
  	'',
  	dashboard.data
  FROM dashboard;


migration_id: create team table
timestamp: 2026-05-07 19:49:49
sql:
  CREATE TABLE IF NOT EXISTS `team` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `name` TEXT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create team member table
timestamp: 2026-05-07 19:49:50
sql:
  CREATE TABLE IF NOT EXISTS `team_member` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `team_id` INTEGER NOT NULL
  , `user_id` INTEGER NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: add unique index team_member_org_id_team_id_user_id
timestamp: 2026-05-07 19:49:50
sql:
  CREATE UNIQUE INDEX `UQE_team_member_org_id_team_id_user_id` ON `team_member` (`org_id`,`team_id`,`user_id`);


migration_id: create dashboard acl table
timestamp: 2026-05-07 19:49:50
sql:
  CREATE TABLE IF NOT EXISTS `dashboard_acl` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `dashboard_id` INTEGER NOT NULL
  , `user_id` INTEGER NULL
  , `team_id` INTEGER NULL
  , `permission` INTEGER NOT NULL DEFAULT 4
  , `role` TEXT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: add unique index dashboard_acl_dashboard_id_user_id
timestamp: 2026-05-07 19:49:50
sql:
  CREATE UNIQUE INDEX `UQE_dashboard_acl_dashboard_id_user_id` ON `dashboard_acl` (`dashboard_id`,`user_id`);


migration_id: add unique index dashboard_acl_dashboard_id_team_id
timestamp: 2026-05-07 19:49:50
sql:
  CREATE UNIQUE INDEX `UQE_dashboard_acl_dashboard_id_team_id` ON `dashboard_acl` (`dashboard_id`,`team_id`);


migration_id: save default acl rules in dashboard_acl table
timestamp: 2026-05-07 19:49:50
sql:
  INSERT INTO dashboard_acl
  	(
  		org_id,
  		dashboard_id,
  		permission,
  		role,
  		created,
  		updated
  	)
  	VALUES
  		(-1,-1, 1,'Viewer','2017-06-20','2017-06-20'),
  		(-1,-1, 2,'Editor','2017-06-20','2017-06-20')
  	


migration_id: delete acl rules for deleted dashboards and folders
timestamp: 2026-05-07 19:49:50
sql:
  DELETE FROM dashboard_acl WHERE dashboard_id NOT IN (SELECT id FROM dashboard) AND dashboard_id != -1


migration_id: create tag table
timestamp: 2026-05-07 19:49:50
sql:
  CREATE TABLE IF NOT EXISTS `tag` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `key` TEXT NOT NULL
  , `value` TEXT NOT NULL
  );


migration_id: create login attempt table
timestamp: 2026-05-07 19:49:50
sql:
  CREATE TABLE IF NOT EXISTS `login_attempt` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `username` TEXT NOT NULL
  , `ip_address` TEXT NOT NULL
  , `created` DATETIME NOT NULL
  );


migration_id: create login_attempt v2
timestamp: 2026-05-07 19:49:50
sql:
  CREATE TABLE IF NOT EXISTS `login_attempt` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `username` TEXT NOT NULL
  , `ip_address` TEXT NOT NULL
  , `created` INTEGER NOT NULL DEFAULT 0
  );


migration_id: copy login_attempt v1 to v2
timestamp: 2026-05-07 19:49:50
sql:
  INSERT INTO `login_attempt` (`id`
  , `username`
  , `ip_address`)
  SELECT `id`
  , `username`
  , `ip_address`
  FROM `login_attempt_tmp_qwerty`


migration_id: create user auth table
timestamp: 2026-05-07 19:49:50
sql:
  CREATE TABLE IF NOT EXISTS `user_auth` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `user_id` INTEGER NOT NULL
  , `auth_module` TEXT NOT NULL
  , `auth_id` TEXT NOT NULL
  , `created` DATETIME NOT NULL
  );


migration_id: Populate user_uid in user_auth from user table
timestamp: 2026-05-07 19:49:51
sql:
  			UPDATE user_auth
  			SET user_uid = (
  				SELECT uid
  				FROM user
  				WHERE user.id = user_auth.user_id
  			)
  			WHERE user_id IN (SELECT id FROM user)
  			AND user_uid IS NULL
  		


migration_id: create server_lock table
timestamp: 2026-05-07 19:49:51
sql:
  CREATE TABLE IF NOT EXISTS `server_lock` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `operation_uid` TEXT NOT NULL
  , `version` INTEGER NOT NULL
  , `last_execution` INTEGER NOT NULL
  );


migration_id: create user auth token table
timestamp: 2026-05-07 19:49:51
sql:
  CREATE TABLE IF NOT EXISTS `user_auth_token` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `user_id` INTEGER NOT NULL
  , `auth_token` TEXT NOT NULL
  , `prev_auth_token` TEXT NOT NULL
  , `user_agent` TEXT NOT NULL
  , `client_ip` TEXT NOT NULL
  , `auth_token_seen` INTEGER NOT NULL
  , `seen_at` INTEGER NULL
  , `rotated_at` INTEGER NOT NULL
  , `created_at` INTEGER NOT NULL
  , `updated_at` INTEGER NOT NULL
  );


migration_id: create cache_data table
timestamp: 2026-05-07 19:49:51
sql:
  CREATE TABLE IF NOT EXISTS `cache_data` (
  `cache_key` TEXT PRIMARY KEY NOT NULL
  , `data` BLOB NOT NULL
  , `expires` INTEGER NOT NULL
  , `created_at` INTEGER NOT NULL
  );


migration_id: create short_url table v1
timestamp: 2026-05-07 19:49:51
sql:
  CREATE TABLE IF NOT EXISTS `short_url` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `uid` TEXT NOT NULL
  , `path` TEXT NOT NULL
  , `created_by` INTEGER NOT NULL
  , `created_at` INTEGER NOT NULL
  , `last_seen_at` INTEGER NULL
  );


migration_id: recreate alert_definition table
timestamp: 2026-05-07 19:49:51
sql:
  CREATE TABLE IF NOT EXISTS `alert_definition` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `title` TEXT NOT NULL
  , `condition` TEXT NOT NULL
  , `data` TEXT NOT NULL
  , `updated` DATETIME NOT NULL
  , `interval_seconds` INTEGER NOT NULL DEFAULT 60
  , `version` INTEGER NOT NULL DEFAULT 0
  , `uid` TEXT NOT NULL DEFAULT 0
  );


migration_id: recreate alert_definition_version table
timestamp: 2026-05-07 19:49:51
sql:
  CREATE TABLE IF NOT EXISTS `alert_definition_version` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `alert_definition_id` INTEGER NOT NULL
  , `alert_definition_uid` TEXT NOT NULL DEFAULT 0
  , `parent_version` INTEGER NOT NULL
  , `restored_from` INTEGER NOT NULL
  , `version` INTEGER NOT NULL
  , `created` DATETIME NOT NULL
  , `title` TEXT NOT NULL
  , `condition` TEXT NOT NULL
  , `data` TEXT NOT NULL
  , `interval_seconds` INTEGER NOT NULL
  );


migration_id: add index in alert_definition_version table on alert_definition_id and version columns
timestamp: 2026-05-07 19:49:51
sql:
  CREATE UNIQUE INDEX `UQE_alert_definition_version_alert_definition_id_version` ON `alert_definition_version` (`alert_definition_id`,`version`);


migration_id: add index in alert_definition_version table on alert_definition_uid and version columns
timestamp: 2026-05-07 19:49:51
sql:
  CREATE UNIQUE INDEX `UQE_alert_definition_version_alert_definition_uid_version` ON `alert_definition_version` (`alert_definition_uid`,`version`);


migration_id: create alert_instance table
timestamp: 2026-05-07 19:49:51
sql:
  CREATE TABLE IF NOT EXISTS `alert_instance` (
  `def_org_id` INTEGER NOT NULL
  , `def_uid` TEXT NOT NULL DEFAULT 0
  , `labels` TEXT NOT NULL
  , `labels_hash` TEXT NOT NULL
  , `current_state` TEXT NOT NULL
  , `current_state_since` INTEGER NOT NULL
  , `last_eval_time` INTEGER NOT NULL
  , PRIMARY KEY ( `def_org_id`,`def_uid`,`labels_hash` ));


migration_id: add index in alert_instance table on def_org_id, def_uid and current_state columns
timestamp: 2026-05-07 19:49:51
sql:
  CREATE INDEX `IDX_alert_instance_def_org_id_def_uid_current_state` ON `alert_instance` (`def_org_id`,`def_uid`,`current_state`);


migration_id: add index in alert_instance table on def_org_id, current_state columns
timestamp: 2026-05-07 19:49:51
sql:
  CREATE INDEX `IDX_alert_instance_def_org_id_current_state` ON `alert_instance` (`def_org_id`,`current_state`);


migration_id: add index rule_org_id, rule_uid, current_state on alert_instance
timestamp: 2026-05-07 19:49:52
sql:
  CREATE INDEX `IDX_alert_instance_rule_org_id_rule_uid_current_state` ON `alert_instance` (`rule_org_id`,`rule_uid`,`current_state`);


migration_id: add index rule_org_id, current_state on alert_instance
timestamp: 2026-05-07 19:49:52
sql:
  CREATE INDEX `IDX_alert_instance_rule_org_id_current_state` ON `alert_instance` (`rule_org_id`,`current_state`);


migration_id: create alert_rule table
timestamp: 2026-05-07 19:49:52
sql:
  CREATE TABLE IF NOT EXISTS `alert_rule` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `title` TEXT NOT NULL
  , `condition` TEXT NOT NULL
  , `data` TEXT NOT NULL
  , `updated` DATETIME NOT NULL
  , `interval_seconds` INTEGER NOT NULL DEFAULT 60
  , `version` INTEGER NOT NULL DEFAULT 0
  , `uid` TEXT NOT NULL DEFAULT 0
  , `namespace_uid` TEXT NOT NULL
  , `rule_group` TEXT NOT NULL
  , `no_data_state` TEXT NOT NULL DEFAULT 'NoData'
  , `exec_err_state` TEXT NOT NULL DEFAULT 'Alerting'
  );


migration_id: add index in alert_rule on org_id, namespace_uid, group_uid columns
timestamp: 2026-05-07 19:49:52
sql:
  CREATE INDEX `IDX_alert_rule_org_id_namespace_uid_rule_group` ON `alert_rule` (`org_id`,`namespace_uid`,`rule_group`);


migration_id: add index in alert_rule on org_id, namespase_uid and title columns
timestamp: 2026-05-07 19:49:52
sql:
  CREATE UNIQUE INDEX `UQE_alert_rule_org_id_namespace_uid_title` ON `alert_rule` (`org_id`,`namespace_uid`,`title`);


migration_id: add index in alert_rule on org_id, dashboard_uid and panel_id columns
timestamp: 2026-05-07 19:49:52
sql:
  CREATE INDEX `IDX_alert_rule_org_id_dashboard_uid_panel_id` ON `alert_rule` (`org_id`,`dashboard_uid`,`panel_id`);


migration_id: create alert_rule_version table
timestamp: 2026-05-07 19:49:52
sql:
  CREATE TABLE IF NOT EXISTS `alert_rule_version` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `rule_org_id` INTEGER NOT NULL
  , `rule_uid` TEXT NOT NULL DEFAULT 0
  , `rule_namespace_uid` TEXT NOT NULL
  , `rule_group` TEXT NOT NULL
  , `parent_version` INTEGER NOT NULL
  , `restored_from` INTEGER NOT NULL
  , `version` INTEGER NOT NULL
  , `created` DATETIME NOT NULL
  , `title` TEXT NOT NULL
  , `condition` TEXT NOT NULL
  , `data` TEXT NOT NULL
  , `interval_seconds` INTEGER NOT NULL
  , `no_data_state` TEXT NOT NULL DEFAULT 'NoData'
  , `exec_err_state` TEXT NOT NULL DEFAULT 'Alerting'
  );


migration_id: add index in alert_rule_version table on rule_org_id, rule_uid and version columns
timestamp: 2026-05-07 19:49:52
sql:
  CREATE UNIQUE INDEX `UQE_alert_rule_version_rule_org_id_rule_uid_version` ON `alert_rule_version` (`rule_org_id`,`rule_uid`,`version`);


migration_id: add index in alert_rule_version table on rule_org_id, rule_namespace_uid and rule_group columns
timestamp: 2026-05-07 19:49:52
sql:
  CREATE INDEX `IDX_alert_rule_version_rule_org_id_rule_namespace_uid_rule_group` ON `alert_rule_version` (`rule_org_id`,`rule_namespace_uid`,`rule_group`);


migration_id: create_alert_configuration_table
timestamp: 2026-05-07 19:49:52
sql:
  CREATE TABLE IF NOT EXISTS `alert_configuration` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `alertmanager_configuration` TEXT NOT NULL
  , `configuration_version` TEXT NOT NULL
  , `created_at` INTEGER NOT NULL
  );


migration_id: add configuration_hash column to alert_configuration
timestamp: 2026-05-07 19:49:53
sql:
  alter table `alert_configuration` ADD COLUMN `configuration_hash` TEXT NOT NULL DEFAULT 'not-yet-calculated' 


migration_id: create_ngalert_configuration_table
timestamp: 2026-05-07 19:49:53
sql:
  CREATE TABLE IF NOT EXISTS `ngalert_configuration` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `alertmanagers` TEXT NULL
  , `created_at` INTEGER NOT NULL
  , `updated_at` INTEGER NOT NULL
  );


migration_id: create provenance_type table
timestamp: 2026-05-07 19:49:53
sql:
  CREATE TABLE IF NOT EXISTS `provenance_type` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `record_key` TEXT NOT NULL
  , `record_type` TEXT NOT NULL
  , `provenance` TEXT NOT NULL
  );


migration_id: add index to uniquify (record_key, record_type, org_id) columns
timestamp: 2026-05-07 19:49:53
sql:
  CREATE UNIQUE INDEX `UQE_provenance_type_record_type_record_key_org_id` ON `provenance_type` (`record_type`,`record_key`,`org_id`);


migration_id: create alert_image table
timestamp: 2026-05-07 19:49:53
sql:
  CREATE TABLE IF NOT EXISTS `alert_image` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `token` TEXT NOT NULL
  , `path` TEXT NOT NULL
  , `url` TEXT NOT NULL
  , `created_at` DATETIME NOT NULL
  , `expires_at` DATETIME NOT NULL
  );


migration_id: create_alert_configuration_history_table
timestamp: 2026-05-07 19:49:53
sql:
  CREATE TABLE IF NOT EXISTS `alert_configuration_history` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL DEFAULT 0
  , `alertmanager_configuration` TEXT NOT NULL
  , `configuration_hash` TEXT NOT NULL DEFAULT 'not-yet-calculated'
  , `configuration_version` TEXT NOT NULL
  , `created_at` INTEGER NOT NULL
  , `default` INTEGER NOT NULL DEFAULT 0
  );


migration_id: create library_element table v1
timestamp: 2026-05-07 19:49:53
sql:
  CREATE TABLE IF NOT EXISTS `library_element` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `folder_id` INTEGER NOT NULL
  , `uid` TEXT NOT NULL
  , `name` TEXT NOT NULL
  , `kind` INTEGER NOT NULL
  , `type` TEXT NOT NULL
  , `description` TEXT NOT NULL
  , `model` TEXT NOT NULL
  , `created` DATETIME NOT NULL
  , `created_by` INTEGER NOT NULL
  , `updated` DATETIME NOT NULL
  , `updated_by` INTEGER NOT NULL
  , `version` INTEGER NOT NULL
  );


migration_id: add index library_element org_id-folder_id-name-kind
timestamp: 2026-05-07 19:49:53
sql:
  CREATE UNIQUE INDEX `UQE_library_element_org_id_folder_id_name_kind` ON `library_element` (`org_id`,`folder_id`,`name`,`kind`);


migration_id: create library_element_connection table v1
timestamp: 2026-05-07 19:49:53
sql:
  CREATE TABLE IF NOT EXISTS `library_element_connection` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `element_id` INTEGER NOT NULL
  , `kind` INTEGER NOT NULL
  , `connection_id` INTEGER NOT NULL
  , `created` DATETIME NOT NULL
  , `created_by` INTEGER NOT NULL
  );


migration_id: add index library_element_connection element_id-kind-connection_id
timestamp: 2026-05-07 19:49:53
sql:
  CREATE UNIQUE INDEX `UQE_library_element_connection_element_id_kind_connection_id` ON `library_element_connection` (`element_id`,`kind`,`connection_id`);


migration_id: populate library_element folder_uid
timestamp: 2026-05-07 19:49:53
sql:
  UPDATE library_element
  	SET folder_uid = dashboard.uid
  	FROM dashboard
  	WHERE library_element.folder_id = dashboard.id AND library_element.org_id = dashboard.org_id


migration_id: add index library_element org_id-folder_uid-name-kind
timestamp: 2026-05-07 19:49:53
sql:
  CREATE UNIQUE INDEX `UQE_library_element_org_id_folder_uid_name_kind` ON `library_element` (`org_id`,`folder_uid`,`name`,`kind`);


migration_id: create data_keys table
timestamp: 2026-05-07 19:49:53
sql:
  CREATE TABLE IF NOT EXISTS `data_keys` (
  `name` TEXT PRIMARY KEY NOT NULL
  , `active` INTEGER NOT NULL
  , `scope` TEXT NOT NULL
  , `provider` TEXT NOT NULL
  , `encrypted_data` BLOB NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create secrets table
timestamp: 2026-05-07 19:49:53
sql:
  CREATE TABLE IF NOT EXISTS `secrets` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `namespace` TEXT NOT NULL
  , `type` TEXT NOT NULL
  , `value` TEXT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create kv_store table v1
timestamp: 2026-05-07 19:49:53
sql:
  CREATE TABLE IF NOT EXISTS `kv_store` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `namespace` TEXT NOT NULL
  , `key` TEXT NOT NULL
  , `value` TEXT NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create permission table
timestamp: 2026-05-07 19:49:54
sql:
  CREATE TABLE IF NOT EXISTS `permission` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `role_id` INTEGER NOT NULL
  , `action` TEXT NOT NULL
  , `scope` TEXT NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: add unique index role_id_action_scope
timestamp: 2026-05-07 19:49:54
sql:
  CREATE UNIQUE INDEX `UQE_permission_role_id_action_scope` ON `permission` (`role_id`,`action`,`scope`);


migration_id: create role table
timestamp: 2026-05-07 19:49:54
sql:
  CREATE TABLE IF NOT EXISTS `role` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `name` TEXT NOT NULL
  , `description` TEXT NULL
  , `version` INTEGER NOT NULL
  , `org_id` INTEGER NOT NULL
  , `uid` TEXT NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create team role table
timestamp: 2026-05-07 19:49:54
sql:
  CREATE TABLE IF NOT EXISTS `team_role` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `team_id` INTEGER NOT NULL
  , `role_id` INTEGER NOT NULL
  , `created` DATETIME NOT NULL
  );


migration_id: add unique index team_role_org_id_team_id_role_id
timestamp: 2026-05-07 19:49:54
sql:
  CREATE UNIQUE INDEX `UQE_team_role_org_id_team_id_role_id` ON `team_role` (`org_id`,`team_id`,`role_id`);


migration_id: create user role table
timestamp: 2026-05-07 19:49:54
sql:
  CREATE TABLE IF NOT EXISTS `user_role` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `user_id` INTEGER NOT NULL
  , `role_id` INTEGER NOT NULL
  , `created` DATETIME NOT NULL
  );


migration_id: add unique index user_role_org_id_user_id_role_id
timestamp: 2026-05-07 19:49:54
sql:
  CREATE UNIQUE INDEX `UQE_user_role_org_id_user_id_role_id` ON `user_role` (`org_id`,`user_id`,`role_id`);


migration_id: create builtin role table
timestamp: 2026-05-07 19:49:54
sql:
  CREATE TABLE IF NOT EXISTS `builtin_role` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `role` TEXT NOT NULL
  , `role_id` INTEGER NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: add unique index builtin_role_org_id_role_id_role
timestamp: 2026-05-07 19:49:54
sql:
  CREATE UNIQUE INDEX `UQE_builtin_role_org_id_role_id_role` ON `builtin_role` (`org_id`,`role_id`,`role`);


migration_id: create seed assignment table
timestamp: 2026-05-07 19:49:54
sql:
  CREATE TABLE IF NOT EXISTS `seed_assignment` (
  `builtin_role` TEXT NOT NULL
  , `role_name` TEXT NOT NULL
  );


migration_id: add unique index builtin_role_role_name
timestamp: 2026-05-07 19:49:54
sql:
  CREATE UNIQUE INDEX `UQE_seed_assignment_builtin_role_role_name` ON `seed_assignment` (`builtin_role`,`role_name`);


migration_id: add permission action scope role_id index
timestamp: 2026-05-07 19:49:54
sql:
  CREATE UNIQUE INDEX `UQE_permission_action_scope_role_id` ON `permission` (`action`,`scope`,`role_id`);


migration_id: add user_role org ID, user ID, role ID, group mapping UID index
timestamp: 2026-05-07 19:49:54
sql:
  CREATE UNIQUE INDEX `UQE_user_role_org_id_user_id_role_id_group_mapping_uid` ON `user_role` (`org_id`,`user_id`,`role_id`,`group_mapping_uid`);


migration_id: create query_history table v1
timestamp: 2026-05-07 19:49:54
sql:
  CREATE TABLE IF NOT EXISTS `query_history` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `uid` TEXT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `datasource_uid` TEXT NOT NULL
  , `created_by` INTEGER NOT NULL
  , `created_at` INTEGER NOT NULL
  , `comment` TEXT NOT NULL
  , `queries` TEXT NOT NULL
  );


migration_id: add index query_history.org_id-created_by-datasource_uid
timestamp: 2026-05-07 19:49:54
sql:
  CREATE INDEX `IDX_query_history_org_id_created_by_datasource_uid` ON `query_history` (`org_id`,`created_by`,`datasource_uid`);


migration_id: create query_history_details table v1
timestamp: 2026-05-07 19:49:55
sql:
  CREATE TABLE IF NOT EXISTS `query_history_details` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `query_history_item_uid` TEXT NOT NULL
  , `datasource_uid` TEXT NOT NULL
  );


migration_id: create query_history_star table v1
timestamp: 2026-05-07 19:49:55
sql:
  CREATE TABLE IF NOT EXISTS `query_history_star` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `query_uid` TEXT NOT NULL
  , `user_id` INTEGER NOT NULL
  );


migration_id: add index query_history.user_id-query_uid
timestamp: 2026-05-07 19:49:55
sql:
  CREATE UNIQUE INDEX `UQE_query_history_star_user_id_query_uid` ON `query_history_star` (`user_id`,`query_uid`);


migration_id: create correlation table v1
timestamp: 2026-05-07 19:49:55
sql:
  CREATE TABLE IF NOT EXISTS `correlation` (
  `uid` TEXT NOT NULL
  , `source_uid` TEXT NOT NULL
  , `target_uid` TEXT NULL
  , `label` TEXT NOT NULL
  , `description` TEXT NOT NULL
  , PRIMARY KEY ( `uid`,`source_uid` ));


migration_id: create correlation v2
timestamp: 2026-05-07 19:49:55
sql:
  CREATE TABLE IF NOT EXISTS `correlation` (
  `uid` TEXT NOT NULL
  , `org_id` INTEGER NOT NULL DEFAULT 0
  , `source_uid` TEXT NOT NULL
  , `target_uid` TEXT NULL
  , `label` TEXT NOT NULL
  , `description` TEXT NOT NULL
  , `config` TEXT NULL
  , PRIMARY KEY ( `uid`,`org_id`,`source_uid` ));


migration_id: copy correlation v1 to v2
timestamp: 2026-05-07 19:49:55
sql:
  INSERT INTO `correlation` (`description`
  , `config`
  , `uid`
  , `source_uid`
  , `target_uid`
  , `label`)
  SELECT `description`
  , `config`
  , `uid`
  , `source_uid`
  , `target_uid`
  , `label`
  FROM `correlation_tmp_qwerty`


migration_id: create entity_events table
timestamp: 2026-05-07 19:49:55
sql:
  CREATE TABLE IF NOT EXISTS `entity_event` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `entity_id` TEXT NOT NULL
  , `event_type` TEXT NOT NULL
  , `created` INTEGER NOT NULL
  );


migration_id: create dashboard public config v1
timestamp: 2026-05-07 19:49:55
sql:
  CREATE TABLE IF NOT EXISTS `dashboard_public_config` (
  `uid` TEXT PRIMARY KEY NOT NULL
  , `dashboard_uid` TEXT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `time_settings` TEXT NOT NULL
  , `refresh_rate` INTEGER NOT NULL DEFAULT 30
  , `template_variables` TEXT NULL
  );


migration_id: create index IDX_dashboard_public_config_org_id_dashboard_uid - v1
timestamp: 2026-05-07 19:49:55
sql:
  CREATE INDEX `IDX_dashboard_public_config_org_id_dashboard_uid` ON `dashboard_public_config` (`org_id`,`dashboard_uid`);


migration_id: Recreate dashboard public config v2
timestamp: 2026-05-07 19:49:55
sql:
  CREATE TABLE IF NOT EXISTS `dashboard_public_config` (
  `uid` TEXT PRIMARY KEY NOT NULL
  , `dashboard_uid` TEXT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `time_settings` TEXT NULL
  , `template_variables` TEXT NULL
  , `access_token` TEXT NOT NULL
  , `created_by` INTEGER NOT NULL
  , `updated_by` INTEGER NULL
  , `created_at` DATETIME NOT NULL
  , `updated_at` DATETIME NULL
  , `is_enabled` INTEGER NOT NULL DEFAULT 0
  );


migration_id: create index UQE_dashboard_public_config_access_token - v2
timestamp: 2026-05-07 19:49:55
sql:
  CREATE UNIQUE INDEX `UQE_dashboard_public_config_access_token` ON `dashboard_public_config` (`access_token`);


migration_id: create file table
timestamp: 2026-05-07 19:49:55
sql:
  CREATE TABLE IF NOT EXISTS `file` (
  `path` TEXT NOT NULL
  , `path_hash` TEXT NOT NULL
  , `parent_folder_path_hash` TEXT NOT NULL
  , `contents` BLOB NOT NULL
  , `etag` TEXT NOT NULL
  , `cache_control` TEXT NOT NULL
  , `content_disposition` TEXT NOT NULL
  , `updated` DATETIME NOT NULL
  , `created` DATETIME NOT NULL
  , `size` INTEGER NOT NULL
  , `mime_type` TEXT NOT NULL
  );


migration_id: create file_meta table
timestamp: 2026-05-07 19:49:55
sql:
  CREATE TABLE IF NOT EXISTS `file_meta` (
  `path_hash` TEXT NOT NULL
  , `key` TEXT NOT NULL
  , `value` TEXT NOT NULL
  );


migration_id: add primary key to file table (postgres and sqlite)
timestamp: 2026-05-07 19:49:56
sql:
  		-- For SQLite we need to recreate the table with primary key. CREATE TABLE was generated by ".schema file" command after running migration.
  		CREATE TABLE file_new
  		(
  			path                    TEXT     NOT NULL,
  			path_hash               TEXT     NOT NULL,
  			parent_folder_path_hash TEXT     NOT NULL,
  			contents                BLOB     NOT NULL,
  			etag                    TEXT     NOT NULL,
  			cache_control           TEXT     NOT NULL,
  			content_disposition     TEXT     NOT NULL,
  			updated                 DATETIME NOT NULL,
  			created                 DATETIME NOT NULL,
  			size                    INTEGER  NOT NULL,
  			mime_type               TEXT     NOT NULL,

  			PRIMARY KEY (path_hash)
  		);

  		INSERT INTO file_new (path, path_hash, parent_folder_path_hash, contents, etag, cache_control, content_disposition, updated, created, size, mime_type)
  		SELECT path, path_hash, parent_folder_path_hash, contents, etag, cache_control, content_disposition, updated, created, size, mime_type FROM file;

  		DROP TABLE file;
  		ALTER TABLE file_new RENAME TO file;

  		CREATE INDEX IDX_file_parent_folder_path_hash ON file (parent_folder_path_hash);
  	


timestamp: 2026-05-07 19:49:56
migration_id:
  drop my_row_id and add primary key to file_meta table if my_row_id exists (auto-generated mysql column)


migration_id: add primary key to file_meta table (postgres and sqlite)
timestamp: 2026-05-07 19:49:56
sql:
  		-- For SQLite we need to recreate the table with primary key. CREATE TABLE was generated by ".schema file_meta" command after running migration.
  		CREATE TABLE file_meta_new
  		(
  			path_hash TEXT NOT NULL,
  			key       TEXT NOT NULL,
  			value     TEXT NOT NULL,

  			PRIMARY KEY (path_hash, key)
  		);

  		INSERT INTO file_meta_new (path_hash, key, value)
  		SELECT path_hash, key, value FROM file_meta;

  		DROP TABLE file_meta;
  		ALTER TABLE file_meta_new RENAME TO file_meta;
  	


migration_id: update seed_assignment role_name column to nullable
timestamp: 2026-05-07 19:49:56
sql:
  ALTER TABLE seed_assignment ADD COLUMN tmp_role_name VARCHAR(190) DEFAULT NULL;
  UPDATE seed_assignment SET tmp_role_name = role_name;
  ALTER TABLE seed_assignment DROP COLUMN role_name;
  ALTER TABLE seed_assignment RENAME COLUMN tmp_role_name TO role_name;


migration_id: add unique index builtin_role_action_scope
timestamp: 2026-05-07 19:49:57
sql:
  CREATE UNIQUE INDEX `UQE_seed_assignment_builtin_role_action_scope` ON `seed_assignment` (`builtin_role`,`action`,`scope`);


migration_id: create folder table
timestamp: 2026-05-07 19:49:57
sql:
  CREATE TABLE IF NOT EXISTS `folder` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `uid` TEXT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `title` TEXT NOT NULL
  , `description` TEXT NULL
  , `parent_uid` TEXT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: Add unique index for title, parent_uid, and org_id
timestamp: 2026-05-07 19:49:57
sql:
  CREATE UNIQUE INDEX `UQE_folder_title_parent_uid_org_id` ON `folder` (`title`,`parent_uid`,`org_id`);


migration_id: Sync dashboard and folder table
timestamp: 2026-05-07 19:49:57
sql:
  			INSERT INTO folder (uid, org_id, title, created, updated)
  			SELECT uid, org_id, title, created, updated FROM dashboard WHERE is_folder = 1
  			ON CONFLICT DO UPDATE SET title=excluded.title, updated=excluded.updated
  		


migration_id: Remove ghost folders from the folder table
timestamp: 2026-05-07 19:49:57
sql:
  			DELETE FROM folder WHERE NOT EXISTS
  				(SELECT 1 FROM dashboard WHERE dashboard.uid = folder.uid AND dashboard.org_id = folder.org_id AND dashboard.is_folder = true)
  	


migration_id: Add unique index UQE_folder_org_id_parent_uid_title
timestamp: 2026-05-07 19:49:57
sql:
  CREATE UNIQUE INDEX `UQE_folder_org_id_parent_uid_title` ON `folder` (`org_id`,`parent_uid`,`title`);


migration_id: create anon_device table
timestamp: 2026-05-07 19:49:57
sql:
  CREATE TABLE IF NOT EXISTS `anon_device` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `client_ip` TEXT NOT NULL
  , `created_at` DATETIME NOT NULL
  , `device_id` TEXT NOT NULL
  , `updated_at` DATETIME NOT NULL
  , `user_agent` TEXT NOT NULL
  );


migration_id: create signing_key table
timestamp: 2026-05-07 19:49:57
sql:
  CREATE TABLE IF NOT EXISTS `signing_key` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `key_id` TEXT NOT NULL
  , `private_key` TEXT NOT NULL
  , `added_at` DATETIME NOT NULL
  , `expires_at` DATETIME NULL
  , `alg` TEXT NOT NULL
  );


migration_id: Add unique index for dashboard_org_id_folder_uid_title_is_folder
timestamp: 2026-05-07 19:49:58
sql:
  CREATE UNIQUE INDEX `UQE_dashboard_org_id_folder_uid_title_is_folder` ON `dashboard` (`org_id`,`folder_uid`,`title`,`is_folder`);


migration_id: create sso_setting table
timestamp: 2026-05-07 19:49:58
sql:
  CREATE TABLE IF NOT EXISTS `sso_setting` (
  `id` TEXT PRIMARY KEY NOT NULL
  , `provider` TEXT NOT NULL
  , `settings` TEXT NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  , `is_deleted` INTEGER NOT NULL DEFAULT 0
  );


migration_id: create cloud_migration table v1
timestamp: 2026-05-07 19:49:58
sql:
  CREATE TABLE IF NOT EXISTS `cloud_migration` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `auth_token` TEXT NULL
  , `stack` TEXT NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create cloud_migration_run table v1
timestamp: 2026-05-07 19:49:58
sql:
  CREATE TABLE IF NOT EXISTS `cloud_migration_run` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `cloud_migration_uid` TEXT NULL
  , `result` TEXT NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  , `finished` DATETIME NULL
  );


migration_id: create cloud_migration_session v2
timestamp: 2026-05-07 19:49:59
sql:
  CREATE TABLE IF NOT EXISTS `cloud_migration_session` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `uid` TEXT NULL
  , `auth_token` TEXT NULL
  , `slug` TEXT NOT NULL
  , `stack_id` INTEGER NOT NULL
  , `region_slug` TEXT NOT NULL
  , `cluster_slug` TEXT NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: copy cloud_migration_session v1 to v2
timestamp: 2026-05-07 19:49:59
sql:
  INSERT INTO `cloud_migration_session` (`auth_token`
  , `region_slug`
  , `cluster_slug`
  , `id`
  , `slug`
  , `stack_id`
  , `created`
  , `updated`
  , `uid`)
  SELECT `auth_token`
  , `region_slug`
  , `cluster_slug`
  , `id`
  , `stack`
  , `stack_id`
  , `created`
  , `updated`
  , `uid`
  FROM `cloud_migration_session_tmp_qwerty`


migration_id: create cloud_migration_snapshot v2
timestamp: 2026-05-07 19:49:59
sql:
  CREATE TABLE IF NOT EXISTS `cloud_migration_snapshot` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `uid` TEXT NULL
  , `session_uid` TEXT NULL
  , `result` TEXT NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  , `finished` DATETIME NULL
  );


migration_id: copy cloud_migration_snapshot v1 to v2
timestamp: 2026-05-07 19:49:59
sql:
  INSERT INTO `cloud_migration_snapshot` (`result`
  , `created`
  , `updated`
  , `finished`
  , `id`
  , `uid`
  , `session_uid`)
  SELECT `result`
  , `created`
  , `updated`
  , `finished`
  , `id`
  , `uid`
  , `cloud_migration_uid`
  FROM `cloud_migration_snapshot_tmp_qwerty`


migration_id: create cloud_migration_resource table v1
timestamp: 2026-05-07 19:49:59
sql:
  CREATE TABLE IF NOT EXISTS `cloud_migration_resource` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `uid` TEXT NOT NULL
  , `resource_type` TEXT NOT NULL
  , `resource_uid` TEXT NOT NULL
  , `status` TEXT NOT NULL
  , `error_string` TEXT NULL
  , `snapshot_uid` TEXT NOT NULL
  );


migration_id: create cloud_migration_snapshot_partition table v1
timestamp: 2026-05-07 19:50:00
sql:
  CREATE TABLE IF NOT EXISTS `cloud_migration_snapshot_partition` (
  `snapshot_uid` TEXT NOT NULL
  , `partition_number` INTEGER NOT NULL
  , `resource_type` TEXT NOT NULL
  , `data` BLOB NOT NULL
  );


migration_id: add cloud_migration_snapshot_partition srp_unique index
timestamp: 2026-05-07 19:50:00
sql:
  CREATE UNIQUE INDEX `UQE_cloud_migration_snapshot_partition_srp_unique` ON `cloud_migration_snapshot_partition` (`snapshot_uid`,`resource_type`,`partition_number`);


timestamp: 2026-05-07 19:50:00
migration_id:
  drop my_row_id and add primary key with columns snapshot_uid,resource_type,partition_number to table cloud_migration_snapshot_partition if my_row_id exists (auto-generated mysql column)


timestamp: 2026-05-07 19:50:00
migration_id:
  drop unique index UQE_cloud_migration_snapshot_partition_srp_unique from cloud_migration_snapshot_partition table if it exists (mysql)


timestamp: 2026-05-07 19:50:00
migration_id:
  add primary key with columns snapshot_uid,resource_type,partition_number to table cloud_migration_snapshot_partition if it doesn't exist (mysql)


timestamp: 2026-05-07 19:50:00
migration_id:
  add primary key with columns snapshot_uid,resource_type,partition_number to table cloud_migration_snapshot_partition (postgres and sqlite)

sql:
  CREATE TABLE IF NOT EXISTS `cloud_migration_snapshot_partition_new` (
  `snapshot_uid` TEXT NOT NULL
  , `partition_number` INTEGER NOT NULL
  , `resource_type` TEXT NOT NULL
  , `data` BLOB NOT NULL
  , PRIMARY KEY ( `snapshot_uid`,`resource_type`,`partition_number` ));
  INSERT INTO `cloud_migration_snapshot_partition_new` (`snapshot_uid`
  , `partition_number`
  , `resource_type`
  , `data`)
  SELECT `snapshot_uid`
  , `partition_number`
  , `resource_type`
  , `data`
  FROM `cloud_migration_snapshot_partition`;
  DROP TABLE IF EXISTS `cloud_migration_snapshot_partition`;
  ALTER TABLE `cloud_migration_snapshot_partition_new` RENAME TO `cloud_migration_snapshot_partition`;


migration_id: create user_external_session table
timestamp: 2026-05-07 19:50:02
sql:
  CREATE TABLE IF NOT EXISTS `user_external_session` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `user_auth_id` INTEGER NOT NULL
  , `user_id` INTEGER NOT NULL
  , `auth_module` TEXT NOT NULL
  , `access_token` TEXT NULL
  , `id_token` TEXT NULL
  , `refresh_token` TEXT NULL
  , `session_id` TEXT NULL
  , `session_id_hash` TEXT NULL
  , `name_id` TEXT NULL
  , `name_id_hash` TEXT NULL
  , `expires_at` DATETIME NULL
  , `created_at` DATETIME NOT NULL
  );


migration_id: add alert_rule_state table
timestamp: 2026-05-07 19:50:02
sql:
  CREATE TABLE IF NOT EXISTS `alert_rule_state` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `org_id` INTEGER NOT NULL
  , `rule_uid` TEXT NOT NULL
  , `data` BLOB NOT NULL
  , `updated_at` DATETIME NOT NULL
  );


migration_id: add index to alert_rule_state on org_id and rule_uid columns
timestamp: 2026-05-07 19:50:02
sql:
  CREATE UNIQUE INDEX `UQE_alert_rule_state_org_id_rule_uid` ON `alert_rule_state` (`org_id`,`rule_uid`);


migration_id: add index in alert_rule_version table on rule_org_id, rule_uid, rule_guid and version columns
timestamp: 2026-05-07 19:50:03
sql:
  CREATE UNIQUE INDEX `UQE_alert_rule_version_rule_org_id_rule_uid_rule_guid_version` ON `alert_rule_version` (`rule_org_id`,`rule_uid`,`rule_guid`,`version`);


migration_id: add index in alert_rule_version table on rule_guid and version columns
timestamp: 2026-05-07 19:50:03
sql:
  CREATE UNIQUE INDEX `UQE_alert_rule_version_rule_guid_version` ON `alert_rule_version` (`rule_guid`,`version`);


migration_id: add index in alert_rule on org_id, namespace_uid, rule_group and rule_group_idx columns
timestamp: 2026-05-07 19:50:04
sql:
  CREATE INDEX `IDX_alert_rule_org_id_namespace_uid_rule_group_rule_group_idx` ON `alert_rule` (`org_id`,`namespace_uid`,`rule_group`,`rule_group_idx`);


# user

login: admin
email: admin@localhost
salt: HB7Ukv7bl0
rands: 2OnaiDeGNf
created: 2026-05-07 19:50:05
updated: 2026-05-07 19:50:05
last_seen_at: 2016-05-07 19:50:05
uid: cfldi1pv9rd34b
password:
  bf42b61ace36abddd4403a95017b83af367d40f6e5dbeeac32f992f2d90af566f2e3531092e54d14c7ec64f85ce555e3619e


# alert_configuration

configuration_version: v1
configuration_hash: ee4e03539ba421c50fd380d98cacd307
alertmanager_configuration:
  {
  	"alertmanager_config": {
  		"route": {
  			"receiver": "empty",
  			"group_by": ["grafana_folder", "alertname"]
  		},
  		"receivers": [{
  			"name": "empty"
  		}]
  	}
  }


# role

name: fixed:org.users:writer
uid: fixed_VERj5nayasjgf_Yh0sWqqCkxWlw
created: 2026-05-07 19:50:10
updated: 2026-05-07 19:50:10
display_name: Writer (organizational)
group_name: User administration
description:
  Within a single organization, add a user, invite a user, read information about a user and their role, remove a user from that organization, or change the role of a user.


name: fixed:users:writer
uid: fixed_wjzgHHo_Ux25DJuELn_oiAdB_yM
created: 2026-05-07 19:50:10
updated: 2026-05-07 19:50:10
display_name: Writer (global)
group_name: User administration
description:
  Read and update all attributes and settings for all users in Grafana: update user information, read user information, create or enable or disable a user, make a user a Grafana administrator, sign out a user, update a user’s authentication token, or update quotas for all users.


name: fixed:alerting:reader
uid: fixed_O2oP1_uBFozI2i93klAkcvEWR30
created: 2026-05-07 19:50:11
updated: 2026-05-07 19:50:11
display_name: Full read-only access
group_name: Alerting
description:
  Read alert rules, instances, silences, contact points, and notification policies in Grafana and all external providers


name: fixed:alerting:writer
uid: fixed_-PAZgSJsDlRD8NUg-PFSeH_BkJY
created: 2026-05-07 19:50:11
updated: 2026-05-07 19:50:11
display_name: Full write access
group_name: Alerting
description:
  Add, update and delete alert rules, instances, silences, contact points, and notification policies in Grafana and all external providers


name: fixed:alerting:admin
uid: fixed_ceFufpsSIv8LgBB81M9_NSHydxg
created: 2026-05-07 19:50:11
updated: 2026-05-07 19:50:11
display_name: Full admin access
group_name: Alerting
description:
  Full write access in Grafana and all external providers, including their permissions, protected fields and secrets


name: fixed:alerting.provisioning:writer
uid: fixed_y7pFjdEkxpx5ETdcxPvp0AgRuUo
created: 2026-05-07 19:50:11
updated: 2026-05-07 19:50:11
display_name: Access to alert rules provisioning API
group_name: Alerting
description:
  Manage all alert rules, contact points, notification policies, silences, etc. in the organization via provisioning API.


name: fixed:alerting.provisioning.secrets:reader
uid: fixed_9fmzXXZZG-Od0Amy2ofEG8Uk--c
created: 2026-05-07 19:50:11
updated: 2026-05-07 19:50:11
display_name: Read via Provisioning API + Export Secrets
group_name: Alerting
description:
  Read all alert rules, contact points, notification policies, silences, etc. in the organization via provisioning API and use export with decrypted secrets


name: fixed:alerting.provisioning.provenance:writer
uid: fixed_TORFtFQiHgSlTGnW-ofLa0b3rxI
created: 2026-05-07 19:50:11
updated: 2026-05-07 19:50:11
display_name: Set provisioning status
group_name: Alerting
description:
  Set provisioning status for alerting resources. Should be used together with other regular roles (Notifications Writer and/or Rules Writer)


name: fixed:organization:writer
uid: fixed_Y4jGqDd8w1yCrPwlik8z5Iu8-3M
created: 2026-05-07 19:50:11
updated: 2026-05-07 19:50:11
display_name: Writer
group_name: Organizations
description:
  Read an organization, its quotas, or its preferences. Update organization properties, or its preferences.


name: fixed:organization:maintainer
uid: fixed_CMm-uuBaPUBf4r8XG3jIvxo55bg
created: 2026-05-07 19:50:11
updated: 2026-05-07 19:50:11
display_name: Maintainer
group_name: Organizations
description:
  Create, read, write, or delete an organization. Read or write an organization's quotas. Needs to be assigned globally.


name: fixed:datasources:explorer
uid: fixed_qDzW9mzx9yM91T5Bi8dHUM2muTw
created: 2026-05-07 19:50:11
updated: 2026-05-07 19:50:11
display_name: Explorer
group_name: Data sources
description:
  Enable the Explore and Drilldown features. Data source permissions still apply; you can only query data sources for which you have query permissions.


# secret_migration_log

migration_id: create secret_migration_log table
timestamp: 2026-05-07 19:50:07
sql:
  CREATE TABLE IF NOT EXISTS `secret_migration_log` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `migration_id` TEXT NOT NULL
  , `sql` TEXT NOT NULL
  , `success` INTEGER NOT NULL
  , `error` TEXT NOT NULL
  , `timestamp` DATETIME NOT NULL
  );


migration_id: create table secret_secure_value
timestamp: 2026-05-07 19:50:07
sql:
  CREATE TABLE IF NOT EXISTS `secret_secure_value` (
  `guid` TEXT PRIMARY KEY NOT NULL
  , `name` TEXT NOT NULL
  , `namespace` TEXT NOT NULL
  , `annotations` TEXT NULL
  , `labels` TEXT NULL
  , `created` INTEGER NOT NULL
  , `created_by` TEXT NOT NULL
  , `updated` INTEGER NOT NULL
  , `updated_by` TEXT NOT NULL
  , `external_id` TEXT NOT NULL
  , `active` INTEGER NOT NULL
  , `version` INTEGER NOT NULL
  , `description` TEXT NOT NULL
  , `keeper` TEXT NULL
  , `decrypters` TEXT NULL
  , `ref` TEXT NULL
  );


migration_id: create table secret_secure_value, index: 0
timestamp: 2026-05-07 19:50:07
sql:
  CREATE UNIQUE INDEX `UQE_secret_secure_value_namespace_name_version_active` ON `secret_secure_value` (`namespace`,`name`,`version`,`active`);


migration_id: create table secret_secure_value, index: 1
timestamp: 2026-05-07 19:50:07
sql:
  CREATE UNIQUE INDEX `UQE_secret_secure_value_namespace_name_version` ON `secret_secure_value` (`namespace`,`name`,`version`);


migration_id: create table secret_keeper
timestamp: 2026-05-07 19:50:07
sql:
  CREATE TABLE IF NOT EXISTS `secret_keeper` (
  `guid` TEXT PRIMARY KEY NOT NULL
  , `name` TEXT NOT NULL
  , `namespace` TEXT NOT NULL
  , `annotations` TEXT NULL
  , `labels` TEXT NULL
  , `created` INTEGER NOT NULL
  , `created_by` TEXT NOT NULL
  , `updated` INTEGER NOT NULL
  , `updated_by` TEXT NOT NULL
  , `description` TEXT NOT NULL
  , `type` TEXT NOT NULL
  , `payload` TEXT NULL
  );


migration_id: create table secret_data_key
timestamp: 2026-05-07 19:50:07
sql:
  CREATE TABLE IF NOT EXISTS `secret_data_key` (
  `uid` TEXT PRIMARY KEY NOT NULL
  , `namespace` TEXT NOT NULL
  , `label` TEXT NOT NULL
  , `active` INTEGER NOT NULL
  , `provider` TEXT NOT NULL
  , `encrypted_data` BLOB NOT NULL
  , `created` DATETIME NOT NULL
  , `updated` DATETIME NOT NULL
  );


migration_id: create table secret_encrypted_value
timestamp: 2026-05-07 19:50:07
sql:
  CREATE TABLE IF NOT EXISTS `secret_encrypted_value` (
  `namespace` TEXT NOT NULL
  , `name` TEXT NOT NULL
  , `version` INTEGER NOT NULL
  , `encrypted_data` BLOB NOT NULL
  , `created` INTEGER NOT NULL
  , `updated` INTEGER NOT NULL
  );


migration_id: create table secret_encrypted_value, index: 0
timestamp: 2026-05-07 19:50:07
sql:
  CREATE UNIQUE INDEX `UQE_secret_encrypted_value_namespace_name_version` ON `secret_encrypted_value` (`namespace`,`name`,`version`);


migration_id: create index for list on secret_secure_value
timestamp: 2026-05-07 19:50:07
sql:
  CREATE INDEX `IDX_secret_secure_value_namespace_active_updated` ON `secret_secure_value` (`namespace`,`active`,`updated`);


migration_id: create index for list and read current on secret_data_key
timestamp: 2026-05-07 19:50:07
sql:
  CREATE INDEX `IDX_secret_data_key_namespace_label_active` ON `secret_data_key` (`namespace`,`label`,`active`);


migration_id: add active column index to secret_keeper
timestamp: 2026-05-07 19:50:08
sql:
  CREATE INDEX `IDX_secret_keeper_namespace_name_active` ON `secret_keeper` (`namespace`,`name`,`active`);


timestamp: 2026-05-07 19:50:08
migration_id:
  drop my_row_id and add primary key with columns namespace,name,version to table secret_encrypted_value if my_row_id exists (auto-generated mysql column)


timestamp: 2026-05-07 19:50:08
migration_id:
  drop unique index UQE_secret_encrypted_value_namespace_name_version from secret_encrypted_value table if it exists (mysql)


timestamp: 2026-05-07 19:50:08
migration_id:
  add primary key with columns namespace,name,version to table secret_encrypted_value if it doesn't exist (mysql)


timestamp: 2026-05-07 19:50:08
migration_id:
  add primary key with columns namespace,name,version to table secret_encrypted_value (postgres and sqlite)

sql:
  CREATE TABLE IF NOT EXISTS `secret_encrypted_value_new` (
  `namespace` TEXT NOT NULL
  , `name` TEXT NOT NULL
  , `version` INTEGER NOT NULL
  , `encrypted_data` BLOB NOT NULL
  , `created` INTEGER NOT NULL
  , `updated` INTEGER NOT NULL
  , `data_key_id` TEXT NOT NULL DEFAULT ''
  , PRIMARY KEY ( `namespace`,`name`,`version` ));
  INSERT INTO `secret_encrypted_value_new` (`namespace`
  , `name`
  , `version`
  , `encrypted_data`
  , `created`
  , `updated`
  , `data_key_id`)
  SELECT `namespace`
  , `name`
  , `version`
  , `encrypted_data`
  , `created`
  , `updated`
  , `data_key_id`
  FROM `secret_encrypted_value`;
  DROP TABLE IF EXISTS `secret_encrypted_value`;
  ALTER TABLE `secret_encrypted_value_new` RENAME TO `secret_encrypted_value`;
  CREATE INDEX `IDX_secret_encrypted_value_data_key_id` ON `secret_encrypted_value` (`data_key_id`);


# resource_migration_log

migration_id: create resource_migration_log table
timestamp: 2026-05-07 19:50:08
sql:
  CREATE TABLE IF NOT EXISTS `resource_migration_log` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `migration_id` TEXT NOT NULL
  , `sql` TEXT NOT NULL
  , `success` INTEGER NOT NULL
  , `error` TEXT NOT NULL
  , `timestamp` DATETIME NOT NULL
  );


migration_id: create table resource
timestamp: 2026-05-07 19:50:08
sql:
  CREATE TABLE IF NOT EXISTS `resource` (
  `guid` TEXT PRIMARY KEY NOT NULL
  , `resource_version` INTEGER NULL
  , `group` TEXT NOT NULL
  , `resource` TEXT NOT NULL
  , `namespace` TEXT NOT NULL
  , `name` TEXT NOT NULL
  , `value` TEXT NULL
  , `action` INTEGER NOT NULL
  , `label_set` TEXT NULL
  );


migration_id: create table resource, index: 0
timestamp: 2026-05-07 19:50:08
sql:
  CREATE UNIQUE INDEX `UQE_resource_namespace_group_resource_name` ON `resource` (`namespace`,`group`,`resource`,`name`);


migration_id: create table resource_history
timestamp: 2026-05-07 19:50:08
sql:
  CREATE TABLE IF NOT EXISTS `resource_history` (
  `guid` TEXT PRIMARY KEY NOT NULL
  , `resource_version` INTEGER NULL
  , `group` TEXT NOT NULL
  , `resource` TEXT NOT NULL
  , `namespace` TEXT NOT NULL
  , `name` TEXT NOT NULL
  , `value` TEXT NULL
  , `action` INTEGER NOT NULL
  , `label_set` TEXT NULL
  );


migration_id: create table resource_history, index: 0
timestamp: 2026-05-07 19:50:08
sql:
  CREATE UNIQUE INDEX `UQE_resource_history_namespace_group_name_version` ON `resource_history` (`namespace`,`group`,`resource`,`name`,`resource_version`);


migration_id: create table resource_version
timestamp: 2026-05-07 19:50:08
sql:
  CREATE TABLE IF NOT EXISTS `resource_version` (
  `group` TEXT NOT NULL
  , `resource` TEXT NOT NULL
  , `resource_version` INTEGER NOT NULL
  );


migration_id: create table resource_version, index: 0
timestamp: 2026-05-07 19:50:08
sql:
  CREATE UNIQUE INDEX `UQE_resource_version_group_resource` ON `resource_version` (`group`,`resource`);


migration_id: create table resource_blob
timestamp: 2026-05-07 19:50:08
sql:
  CREATE TABLE IF NOT EXISTS `resource_blob` (
  `uuid` UUID PRIMARY KEY NOT NULL
  , `created` DATETIME NOT NULL
  , `group` TEXT NOT NULL
  , `resource` TEXT NOT NULL
  , `namespace` TEXT NOT NULL
  , `name` TEXT NOT NULL
  , `value` BLOB NOT NULL
  , `hash` TEXT NOT NULL
  , `content_type` TEXT NOT NULL
  );


migration_id: create table resource_blob, index: 0
timestamp: 2026-05-07 19:50:08
sql:
  CREATE INDEX `IDX_resource_history_namespace_group_name` ON `resource_blob` (`namespace`,`group`,`resource`,`name`);


migration_id: create table resource_last_import_time
timestamp: 2026-05-07 19:50:08
sql:
  CREATE TABLE IF NOT EXISTS `resource_last_import_time` (
  `group` TEXT NOT NULL
  , `resource` TEXT NOT NULL
  , `namespace` TEXT NOT NULL
  , `last_import_time` DATETIME NOT NULL
  , PRIMARY KEY ( `group`,`resource`,`namespace` ));


migration_id: Add index to resource_history for polling
timestamp: 2026-05-07 19:50:08
sql:
  CREATE INDEX `IDX_resource_history_group_resource_resource_version` ON `resource_history` (`group`,`resource`,`resource_version`);


migration_id: Add index to resource_history for get trash
timestamp: 2026-05-07 19:50:09
sql:
  CREATE INDEX `IDX_resource_history_namespace_group_resource_action_version` ON `resource_history` (`namespace`,`group`,`resource`,`action`,`resource_version`);


migration_id: Add generation index to resource history
timestamp: 2026-05-07 19:50:09
sql:
  CREATE INDEX `IDX_resource_history_namespace_group_resource_name_generation` ON `resource_history` (`namespace`,`group`,`resource`,`name`,`generation`);


migration_id: Add UQE_resource_last_import_time_last_import_time index
timestamp: 2026-05-07 19:50:09
sql:
  CREATE INDEX `UQE_resource_last_import_time_last_import_time` ON `resource_last_import_time` (`last_import_time`);


migration_id: create table resource_events
timestamp: 2026-05-07 19:50:09
sql:
  CREATE TABLE IF NOT EXISTS `resource_events` (
  `key_path` TEXT PRIMARY KEY NOT NULL
  , `value` TEXT NOT NULL
  );


timestamp: 2026-05-07 19:50:09
migration_id:
  drop my_row_id and add primary key with columns group,resource to table resource_version if my_row_id exists (auto-generated mysql column)


timestamp: 2026-05-07 19:50:09
migration_id:
  drop unique index UQE_resource_version_group_resource from resource_version table if it exists (mysql)


migration_id: add primary key with columns group,resource to table resource_version (postgres and sqlite)
timestamp: 2026-05-07 19:50:09
sql:
  CREATE TABLE IF NOT EXISTS `resource_version_new` (
  `group` TEXT NOT NULL
  , `resource` TEXT NOT NULL
  , `resource_version` INTEGER NOT NULL
  , PRIMARY KEY ( `group`,`resource` ));
  INSERT INTO `resource_version_new` (`group`
  , `resource`
  , `resource_version`)
  SELECT `group`
  , `resource`
  , `resource_version`
  FROM `resource_version`;
  DROP TABLE IF EXISTS `resource_version`;
  ALTER TABLE `resource_version_new` RENAME TO `resource_version`;


migration_id: Add index to resource_history for garbage collection
timestamp: 2026-05-07 19:50:09
sql:
  CREATE INDEX `IDX_resource_history_resource_action_version_name` ON `resource_history` (`group`,`resource`,`action`,`resource_version`,`name`);


# unifiedstorage_migration_log

migration_id: create unifiedstorage_migration_log table
timestamp: 2026-05-07 19:50:09
sql:
  CREATE TABLE IF NOT EXISTS `unifiedstorage_migration_log` (
  `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
  , `migration_id` TEXT NOT NULL
  , `sql` TEXT NOT NULL
  , `success` INTEGER NOT NULL
  , `error` TEXT NOT NULL
  , `timestamp` DATETIME NOT NULL
  );


