diff --git a/backend/internal/bootstrap/db_bootstrap.go b/backend/internal/bootstrap/db_bootstrap.go index eb754f8c..b1b5f04a 100644 --- a/backend/internal/bootstrap/db_bootstrap.go +++ b/backend/internal/bootstrap/db_bootstrap.go @@ -42,7 +42,9 @@ func NewDatabase() (db *gorm.DB, err error) { var driver database.Driver switch common.EnvConfig.DbProvider { case common.DbProviderSqlite: - driver, err = sqliteMigrate.WithInstance(sqlDb, &sqliteMigrate.Config{}) + driver, err = sqliteMigrate.WithInstance(sqlDb, &sqliteMigrate.Config{ + NoTxWrap: true, + }) case common.DbProviderPostgres: driver, err = postgresMigrate.WithInstance(sqlDb, &postgresMigrate.Config{}) default: diff --git a/backend/resources/migrations/sqlite/20240731203656_init.up.sql b/backend/resources/migrations/sqlite/20240731203656_init.up.sql index 54a15016..a5388dd7 100644 --- a/backend/resources/migrations/sqlite/20240731203656_init.up.sql +++ b/backend/resources/migrations/sqlite/20240731203656_init.up.sql @@ -1,3 +1,5 @@ +PRAGMA foreign_keys=OFF; +BEGIN; CREATE TABLE users ( id TEXT NOT NULL PRIMARY KEY, @@ -77,4 +79,6 @@ CREATE TABLE application_configuration_variables type TEXT NOT NULL, is_public NUMERIC DEFAULT FALSE NOT NULL, is_internal NUMERIC DEFAULT FALSE NOT NULL -); \ No newline at end of file +); +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20240813211251_passkey_backup_flags..up.sql b/backend/resources/migrations/sqlite/20240813211251_passkey_backup_flags..up.sql index fcb42a61..f3ee0c87 100644 --- a/backend/resources/migrations/sqlite/20240813211251_passkey_backup_flags..up.sql +++ b/backend/resources/migrations/sqlite/20240813211251_passkey_backup_flags..up.sql @@ -1,2 +1,6 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE webauthn_credentials ADD COLUMN backup_eligible BOOLEAN NOT NULL DEFAULT FALSE; -ALTER TABLE webauthn_credentials ADD COLUMN backup_state BOOLEAN NOT NULL DEFAULT FALSE; \ No newline at end of file +ALTER TABLE webauthn_credentials ADD COLUMN backup_state BOOLEAN NOT NULL DEFAULT FALSE; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20240813211251_passkey_backup_flags.down.sql b/backend/resources/migrations/sqlite/20240813211251_passkey_backup_flags.down.sql index a7eb3fdf..62484054 100644 --- a/backend/resources/migrations/sqlite/20240813211251_passkey_backup_flags.down.sql +++ b/backend/resources/migrations/sqlite/20240813211251_passkey_backup_flags.down.sql @@ -1,2 +1,6 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE webauthn_credentials DROP COLUMN backup_eligible; -ALTER TABLE webauthn_credentials DROP COLUMN backup_state; \ No newline at end of file +ALTER TABLE webauthn_credentials DROP COLUMN backup_state; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20240817191051_rename_config_table.down.sql b/backend/resources/migrations/sqlite/20240817191051_rename_config_table.down.sql index 49996fac..e3feb763 100644 --- a/backend/resources/migrations/sqlite/20240817191051_rename_config_table.down.sql +++ b/backend/resources/migrations/sqlite/20240817191051_rename_config_table.down.sql @@ -1,2 +1,6 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE app_config_variables - RENAME TO application_configuration_variables; \ No newline at end of file + RENAME TO application_configuration_variables; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20240817191051_rename_config_table.up.sql b/backend/resources/migrations/sqlite/20240817191051_rename_config_table.up.sql index 87bbb870..2e097ef1 100644 --- a/backend/resources/migrations/sqlite/20240817191051_rename_config_table.up.sql +++ b/backend/resources/migrations/sqlite/20240817191051_rename_config_table.up.sql @@ -1,2 +1,6 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE application_configuration_variables - RENAME TO app_config_variables; \ No newline at end of file + RENAME TO app_config_variables; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20240820205521_multiple_callback_urls.down.sql b/backend/resources/migrations/sqlite/20240820205521_multiple_callback_urls.down.sql index d099daef..e5189b34 100644 --- a/backend/resources/migrations/sqlite/20240820205521_multiple_callback_urls.down.sql +++ b/backend/resources/migrations/sqlite/20240820205521_multiple_callback_urls.down.sql @@ -1,3 +1,5 @@ +PRAGMA foreign_keys=OFF; +BEGIN; create table oidc_clients ( id TEXT not null primary key, @@ -20,4 +22,6 @@ select id, created_by_id from oidc_clients_dg_tmp; -drop table oidc_clients_dg_tmp; \ No newline at end of file +drop table oidc_clients_dg_tmp; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20240820205521_multiple_callback_urls.up.sql b/backend/resources/migrations/sqlite/20240820205521_multiple_callback_urls.up.sql index 2e29ec9b..7975246a 100644 --- a/backend/resources/migrations/sqlite/20240820205521_multiple_callback_urls.up.sql +++ b/backend/resources/migrations/sqlite/20240820205521_multiple_callback_urls.up.sql @@ -1,3 +1,5 @@ +PRAGMA foreign_keys=OFF; +BEGIN; create table oidc_clients_dg_tmp ( id TEXT not null primary key, @@ -23,4 +25,6 @@ from oidc_clients; drop table oidc_clients; alter table oidc_clients_dg_tmp - rename to oidc_clients; \ No newline at end of file + rename to oidc_clients; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20240908123031_audit_log.down.sql b/backend/resources/migrations/sqlite/20240908123031_audit_log.down.sql index 4abd973b..cbed9f78 100644 --- a/backend/resources/migrations/sqlite/20240908123031_audit_log.down.sql +++ b/backend/resources/migrations/sqlite/20240908123031_audit_log.down.sql @@ -1 +1,5 @@ -DROP TABLE audit_logs; \ No newline at end of file +PRAGMA foreign_keys=OFF; +BEGIN; +DROP TABLE audit_logs; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20240908123031_audit_log.up.sql b/backend/resources/migrations/sqlite/20240908123031_audit_log.up.sql index 90165b68..064d9a0c 100644 --- a/backend/resources/migrations/sqlite/20240908123031_audit_log.up.sql +++ b/backend/resources/migrations/sqlite/20240908123031_audit_log.up.sql @@ -1,3 +1,5 @@ +PRAGMA foreign_keys=OFF; +BEGIN; CREATE TABLE audit_logs ( id TEXT NOT NULL PRIMARY KEY, @@ -7,4 +9,6 @@ CREATE TABLE audit_logs user_agent TEXT NOT NULL, data BLOB NOT NULL, user_id TEXT REFERENCES users -); \ No newline at end of file +); +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20240924202721_user_groups.down.sql b/backend/resources/migrations/sqlite/20240924202721_user_groups.down.sql index 1ea40bfa..39c6db7c 100644 --- a/backend/resources/migrations/sqlite/20240924202721_user_groups.down.sql +++ b/backend/resources/migrations/sqlite/20240924202721_user_groups.down.sql @@ -1,2 +1,6 @@ +PRAGMA foreign_keys=OFF; +BEGIN; DROP TABLE user_groups; -DROP TABLE user_groups_users; \ No newline at end of file +DROP TABLE user_groups_users; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20240924202721_user_groups.up.sql b/backend/resources/migrations/sqlite/20240924202721_user_groups.up.sql index 405c0a01..597a9a8f 100644 --- a/backend/resources/migrations/sqlite/20240924202721_user_groups.up.sql +++ b/backend/resources/migrations/sqlite/20240924202721_user_groups.up.sql @@ -1,3 +1,5 @@ +PRAGMA foreign_keys=OFF; +BEGIN; CREATE TABLE user_groups ( id TEXT NOT NULL PRIMARY KEY, @@ -13,4 +15,6 @@ CREATE TABLE user_groups_users PRIMARY KEY (user_id, user_group_id), FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE, FOREIGN KEY (user_group_id) REFERENCES user_groups (id) ON DELETE CASCADE -); \ No newline at end of file +); +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20241004092030_audit_log_location.down.sql b/backend/resources/migrations/sqlite/20241004092030_audit_log_location.down.sql index ed8a44af..16adb4e8 100644 --- a/backend/resources/migrations/sqlite/20241004092030_audit_log_location.down.sql +++ b/backend/resources/migrations/sqlite/20241004092030_audit_log_location.down.sql @@ -1,2 +1,6 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE audit_logs DROP COLUMN country; -ALTER TABLE audit_logs DROP COLUMN city; \ No newline at end of file +ALTER TABLE audit_logs DROP COLUMN city; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20241004092030_audit_log_location.up.sql b/backend/resources/migrations/sqlite/20241004092030_audit_log_location.up.sql index 5e22bcef..736fa1db 100644 --- a/backend/resources/migrations/sqlite/20241004092030_audit_log_location.up.sql +++ b/backend/resources/migrations/sqlite/20241004092030_audit_log_location.up.sql @@ -1,2 +1,6 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE audit_logs ADD COLUMN country TEXT; -ALTER TABLE audit_logs ADD COLUMN city TEXT; \ No newline at end of file +ALTER TABLE audit_logs ADD COLUMN city TEXT; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20241023072742_unix-timestamps.down.sql b/backend/resources/migrations/sqlite/20241023072742_unix-timestamps.down.sql index 27befe12..8955d214 100644 --- a/backend/resources/migrations/sqlite/20241023072742_unix-timestamps.down.sql +++ b/backend/resources/migrations/sqlite/20241023072742_unix-timestamps.down.sql @@ -1,3 +1,5 @@ +PRAGMA foreign_keys=OFF; +BEGIN; -- Convert the Unix timestamps back to DATETIME format UPDATE user_groups @@ -25,4 +27,6 @@ SET created_at = datetime(created_at, 'unixepoch'); UPDATE webauthn_sessions SET created_at = datetime(created_at, 'unixepoch'), - expires_at = datetime(expires_at, 'unixepoch'); \ No newline at end of file + expires_at = datetime(expires_at, 'unixepoch'); +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20241023072742_unix-timestamps.up.sql b/backend/resources/migrations/sqlite/20241023072742_unix-timestamps.up.sql index de1acb04..25602761 100644 --- a/backend/resources/migrations/sqlite/20241023072742_unix-timestamps.up.sql +++ b/backend/resources/migrations/sqlite/20241023072742_unix-timestamps.up.sql @@ -1,3 +1,5 @@ +PRAGMA foreign_keys=OFF; +BEGIN; -- Convert the DATETIME fields to Unix timestamps (in seconds) UPDATE user_groups SET created_at = strftime('%s', created_at); @@ -24,4 +26,6 @@ SET created_at = strftime('%s', created_at); UPDATE webauthn_sessions SET created_at = strftime('%s', created_at), - expires_at = strftime('%s', expires_at); \ No newline at end of file + expires_at = strftime('%s', expires_at); +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20241025214824_app_config_default_value.down.sql b/backend/resources/migrations/sqlite/20241025214824_app_config_default_value.down.sql index 4acd64d1..a42c0379 100644 --- a/backend/resources/migrations/sqlite/20241025214824_app_config_default_value.down.sql +++ b/backend/resources/migrations/sqlite/20241025214824_app_config_default_value.down.sql @@ -1 +1,5 @@ -ALTER TABLE app_config_variables DROP COLUMN default_value; \ No newline at end of file +PRAGMA foreign_keys=OFF; +BEGIN; +ALTER TABLE app_config_variables DROP COLUMN default_value; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20241025214824_app_config_default_value.up.sql b/backend/resources/migrations/sqlite/20241025214824_app_config_default_value.up.sql index 572af61d..149283dc 100644 --- a/backend/resources/migrations/sqlite/20241025214824_app_config_default_value.up.sql +++ b/backend/resources/migrations/sqlite/20241025214824_app_config_default_value.up.sql @@ -1 +1,5 @@ -ALTER TABLE app_config_variables ADD COLUMN default_value TEXT; \ No newline at end of file +PRAGMA foreign_keys=OFF; +BEGIN; +ALTER TABLE app_config_variables ADD COLUMN default_value TEXT; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20241028064959_custom_claims.down.sql b/backend/resources/migrations/sqlite/20241028064959_custom_claims.down.sql index 113dcb50..c798f794 100644 --- a/backend/resources/migrations/sqlite/20241028064959_custom_claims.down.sql +++ b/backend/resources/migrations/sqlite/20241028064959_custom_claims.down.sql @@ -1 +1,5 @@ -DROP TABLE custom_claims; \ No newline at end of file +PRAGMA foreign_keys=OFF; +BEGIN; +DROP TABLE custom_claims; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20241028064959_custom_claims.up.sql b/backend/resources/migrations/sqlite/20241028064959_custom_claims.up.sql index 9d6acc67..6cdbf779 100644 --- a/backend/resources/migrations/sqlite/20241028064959_custom_claims.up.sql +++ b/backend/resources/migrations/sqlite/20241028064959_custom_claims.up.sql @@ -1,3 +1,5 @@ +PRAGMA foreign_keys=OFF; +BEGIN; CREATE TABLE custom_claims ( id TEXT NOT NULL PRIMARY KEY, @@ -12,4 +14,6 @@ CREATE TABLE custom_claims CONSTRAINT custom_claims_unique UNIQUE (key, user_id, user_group_id), CHECK (user_id IS NOT NULL OR user_group_id IS NOT NULL) -); \ No newline at end of file +); +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20241115131129_pkce.down.sql b/backend/resources/migrations/sqlite/20241115131129_pkce.down.sql index 1ec7b0c1..643bb2b8 100644 --- a/backend/resources/migrations/sqlite/20241115131129_pkce.down.sql +++ b/backend/resources/migrations/sqlite/20241115131129_pkce.down.sql @@ -1,3 +1,7 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE oidc_authorization_codes DROP COLUMN code_challenge; ALTER TABLE oidc_authorization_codes DROP COLUMN code_challenge_method_sha256; -ALTER TABLE oidc_clients DROP COLUMN is_public; \ No newline at end of file +ALTER TABLE oidc_clients DROP COLUMN is_public; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20241115131129_pkce.up.sql b/backend/resources/migrations/sqlite/20241115131129_pkce.up.sql index db4b58a3..20bf6bda 100644 --- a/backend/resources/migrations/sqlite/20241115131129_pkce.up.sql +++ b/backend/resources/migrations/sqlite/20241115131129_pkce.up.sql @@ -1,3 +1,7 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE oidc_authorization_codes ADD COLUMN code_challenge TEXT; ALTER TABLE oidc_authorization_codes ADD COLUMN code_challenge_method_sha256 NUMERIC; -ALTER TABLE oidc_clients ADD COLUMN is_public BOOLEAN DEFAULT FALSE; \ No newline at end of file +ALTER TABLE oidc_clients ADD COLUMN is_public BOOLEAN DEFAULT FALSE; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250103145821_pkce_column.down.sql b/backend/resources/migrations/sqlite/20250103145821_pkce_column.down.sql index dc517ca0..58db76c0 100644 --- a/backend/resources/migrations/sqlite/20250103145821_pkce_column.down.sql +++ b/backend/resources/migrations/sqlite/20250103145821_pkce_column.down.sql @@ -1 +1,5 @@ -ALTER TABLE oidc_clients DROP COLUMN pkce_enabled; \ No newline at end of file +PRAGMA foreign_keys=OFF; +BEGIN; +ALTER TABLE oidc_clients DROP COLUMN pkce_enabled; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250103145821_pkce_column.up.sql b/backend/resources/migrations/sqlite/20250103145821_pkce_column.up.sql index 89a5b537..a6bfc096 100644 --- a/backend/resources/migrations/sqlite/20250103145821_pkce_column.up.sql +++ b/backend/resources/migrations/sqlite/20250103145821_pkce_column.up.sql @@ -1 +1,5 @@ -ALTER TABLE oidc_clients ADD COLUMN pkce_enabled BOOLEAN DEFAULT FALSE; \ No newline at end of file +PRAGMA foreign_keys=OFF; +BEGIN; +ALTER TABLE oidc_clients ADD COLUMN pkce_enabled BOOLEAN DEFAULT FALSE; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250115155817_ldap.down.sql b/backend/resources/migrations/sqlite/20250115155817_ldap.down.sql index 894ce56c..7b62e323 100644 --- a/backend/resources/migrations/sqlite/20250115155817_ldap.down.sql +++ b/backend/resources/migrations/sqlite/20250115155817_ldap.down.sql @@ -1,2 +1,6 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE users DROP COLUMN ldap_id; -ALTER TABLE user_groups DROP COLUMN ldap_id; \ No newline at end of file +ALTER TABLE user_groups DROP COLUMN ldap_id; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250115155817_ldap.up.sql b/backend/resources/migrations/sqlite/20250115155817_ldap.up.sql index 9a6446f2..1fbceb70 100644 --- a/backend/resources/migrations/sqlite/20250115155817_ldap.up.sql +++ b/backend/resources/migrations/sqlite/20250115155817_ldap.up.sql @@ -1,5 +1,9 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE users ADD COLUMN ldap_id TEXT; ALTER TABLE user_groups ADD COLUMN ldap_id TEXT; CREATE UNIQUE INDEX users_ldap_id ON users (ldap_id); -CREATE UNIQUE INDEX user_groups_ldap_id ON user_groups (ldap_id); \ No newline at end of file +CREATE UNIQUE INDEX user_groups_ldap_id ON user_groups (ldap_id); +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250118180712_rename_email_config_variable.down.sql b/backend/resources/migrations/sqlite/20250118180712_rename_email_config_variable.down.sql index 188b5ba9..e2b0076a 100644 --- a/backend/resources/migrations/sqlite/20250118180712_rename_email_config_variable.down.sql +++ b/backend/resources/migrations/sqlite/20250118180712_rename_email_config_variable.down.sql @@ -1 +1,5 @@ -UPDATE app_config_variables SET key = 'emailEnabled' WHERE key = 'emailLoginNotificationEnabled'; \ No newline at end of file +PRAGMA foreign_keys=OFF; +BEGIN; +UPDATE app_config_variables SET key = 'emailEnabled' WHERE key = 'emailLoginNotificationEnabled'; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250118180712_rename_email_config_variable.up.sql b/backend/resources/migrations/sqlite/20250118180712_rename_email_config_variable.up.sql index c31feb71..bb3205d3 100644 --- a/backend/resources/migrations/sqlite/20250118180712_rename_email_config_variable.up.sql +++ b/backend/resources/migrations/sqlite/20250118180712_rename_email_config_variable.up.sql @@ -1 +1,5 @@ -UPDATE app_config_variables SET key = 'emailLoginNotificationEnabled' WHERE key = 'emailEnabled'; \ No newline at end of file +PRAGMA foreign_keys=OFF; +BEGIN; +UPDATE app_config_variables SET key = 'emailLoginNotificationEnabled' WHERE key = 'emailEnabled'; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250120102531_fix_empty_ldap_id_string.down.sql b/backend/resources/migrations/sqlite/20250120102531_fix_empty_ldap_id_string.down.sql index be451acb..eaea2c59 100644 --- a/backend/resources/migrations/sqlite/20250120102531_fix_empty_ldap_id_string.down.sql +++ b/backend/resources/migrations/sqlite/20250120102531_fix_empty_ldap_id_string.down.sql @@ -1,2 +1,6 @@ +PRAGMA foreign_keys=OFF; +BEGIN; UPDATE users SET ldap_id = '' WHERE ldap_id IS NULL; -UPDATE user_groups SET ldap_id = '' WHERE ldap_id IS NULL; \ No newline at end of file +UPDATE user_groups SET ldap_id = '' WHERE ldap_id IS NULL; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250120102531_fix_empty_ldap_id_string.up.sql b/backend/resources/migrations/sqlite/20250120102531_fix_empty_ldap_id_string.up.sql index 01fe893e..c32e437d 100644 --- a/backend/resources/migrations/sqlite/20250120102531_fix_empty_ldap_id_string.up.sql +++ b/backend/resources/migrations/sqlite/20250120102531_fix_empty_ldap_id_string.up.sql @@ -1,2 +1,6 @@ +PRAGMA foreign_keys=OFF; +BEGIN; UPDATE users SET ldap_id = null WHERE ldap_id = ''; -UPDATE user_groups SET ldap_id = null WHERE ldap_id = ''; \ No newline at end of file +UPDATE user_groups SET ldap_id = null WHERE ldap_id = ''; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250131154719_oidc_user_group_restriction.down.sql b/backend/resources/migrations/sqlite/20250131154719_oidc_user_group_restriction.down.sql index 84e25dae..041bd9c2 100644 --- a/backend/resources/migrations/sqlite/20250131154719_oidc_user_group_restriction.down.sql +++ b/backend/resources/migrations/sqlite/20250131154719_oidc_user_group_restriction.down.sql @@ -1 +1,5 @@ -DROP TABLE oidc_clients_allowed_user_groups; \ No newline at end of file +PRAGMA foreign_keys=OFF; +BEGIN; +DROP TABLE oidc_clients_allowed_user_groups; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250131154719_oidc_user_group_restriction.up.sql b/backend/resources/migrations/sqlite/20250131154719_oidc_user_group_restriction.up.sql index 0e191a6f..0746fbb7 100644 --- a/backend/resources/migrations/sqlite/20250131154719_oidc_user_group_restriction.up.sql +++ b/backend/resources/migrations/sqlite/20250131154719_oidc_user_group_restriction.up.sql @@ -1,3 +1,5 @@ +PRAGMA foreign_keys=OFF; +BEGIN; CREATE TABLE oidc_clients_allowed_user_groups ( user_group_id TEXT NOT NULL, @@ -5,4 +7,6 @@ CREATE TABLE oidc_clients_allowed_user_groups PRIMARY KEY (oidc_client_id, user_group_id), FOREIGN KEY (oidc_client_id) REFERENCES oidc_clients (id) ON DELETE CASCADE, FOREIGN KEY (user_group_id) REFERENCES user_groups (id) ON DELETE CASCADE -); \ No newline at end of file +); +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250203082527_fix_empty_user_group_ldap_id_string.down.sql b/backend/resources/migrations/sqlite/20250203082527_fix_empty_user_group_ldap_id_string.down.sql index 14da3749..ac8a92cb 100644 --- a/backend/resources/migrations/sqlite/20250203082527_fix_empty_user_group_ldap_id_string.down.sql +++ b/backend/resources/migrations/sqlite/20250203082527_fix_empty_user_group_ldap_id_string.down.sql @@ -1 +1,5 @@ -UPDATE user_groups SET ldap_id = '' WHERE ldap_id IS NULL; \ No newline at end of file +PRAGMA foreign_keys=OFF; +BEGIN; +UPDATE user_groups SET ldap_id = '' WHERE ldap_id IS NULL; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250203082527_fix_empty_user_group_ldap_id_string.up.sql b/backend/resources/migrations/sqlite/20250203082527_fix_empty_user_group_ldap_id_string.up.sql index 87ee3e09..5f08b121 100644 --- a/backend/resources/migrations/sqlite/20250203082527_fix_empty_user_group_ldap_id_string.up.sql +++ b/backend/resources/migrations/sqlite/20250203082527_fix_empty_user_group_ldap_id_string.up.sql @@ -1 +1,5 @@ -UPDATE user_groups SET ldap_id = null WHERE ldap_id = ''; \ No newline at end of file +PRAGMA foreign_keys=OFF; +BEGIN; +UPDATE user_groups SET ldap_id = null WHERE ldap_id = ''; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250210152631_post_logout_url.down.sql b/backend/resources/migrations/sqlite/20250210152631_post_logout_url.down.sql index b92c022f..bf0a141e 100644 --- a/backend/resources/migrations/sqlite/20250210152631_post_logout_url.down.sql +++ b/backend/resources/migrations/sqlite/20250210152631_post_logout_url.down.sql @@ -1 +1,5 @@ -ALTER TABLE oidc_clients DROP COLUMN logout_callback_urls; \ No newline at end of file +PRAGMA foreign_keys=OFF; +BEGIN; +ALTER TABLE oidc_clients DROP COLUMN logout_callback_urls; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250210152631_post_logout_url.up.sql b/backend/resources/migrations/sqlite/20250210152631_post_logout_url.up.sql index 3c5be975..29c307d9 100644 --- a/backend/resources/migrations/sqlite/20250210152631_post_logout_url.up.sql +++ b/backend/resources/migrations/sqlite/20250210152631_post_logout_url.up.sql @@ -1 +1,5 @@ -ALTER TABLE oidc_clients ADD COLUMN logout_callback_urls BLOB; \ No newline at end of file +PRAGMA foreign_keys=OFF; +BEGIN; +ALTER TABLE oidc_clients ADD COLUMN logout_callback_urls BLOB; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250225182112_manual_smtp_tls_selection.down.sql b/backend/resources/migrations/sqlite/20250225182112_manual_smtp_tls_selection.down.sql index bab75a60..767a5227 100644 --- a/backend/resources/migrations/sqlite/20250225182112_manual_smtp_tls_selection.down.sql +++ b/backend/resources/migrations/sqlite/20250225182112_manual_smtp_tls_selection.down.sql @@ -1 +1,5 @@ -UPDATE app_config_variables SET value = 'true' WHERE key = 'smtpTls'; \ No newline at end of file +PRAGMA foreign_keys=OFF; +BEGIN; +UPDATE app_config_variables SET value = 'true' WHERE key = 'smtpTls'; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250225182112_manual_smtp_tls_selection.up.sql b/backend/resources/migrations/sqlite/20250225182112_manual_smtp_tls_selection.up.sql index ace19a90..dcd28cc9 100644 --- a/backend/resources/migrations/sqlite/20250225182112_manual_smtp_tls_selection.up.sql +++ b/backend/resources/migrations/sqlite/20250225182112_manual_smtp_tls_selection.up.sql @@ -1,7 +1,11 @@ +PRAGMA foreign_keys=OFF; +BEGIN; UPDATE app_config_variables SET value = CASE WHEN value = 'true' AND (SELECT value FROM app_config_variables WHERE key = 'smtpPort' LIMIT 1) = '587' THEN 'starttls' WHEN value = 'true' THEN 'tls' ELSE 'none' END -WHERE key = 'smtpTls'; \ No newline at end of file +WHERE key = 'smtpTls'; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250302220732_api_key_auth.down.sql b/backend/resources/migrations/sqlite/20250302220732_api_key_auth.down.sql index 3669e0ac..19873c10 100644 --- a/backend/resources/migrations/sqlite/20250302220732_api_key_auth.down.sql +++ b/backend/resources/migrations/sqlite/20250302220732_api_key_auth.down.sql @@ -1,2 +1,6 @@ +PRAGMA foreign_keys=OFF; +BEGIN; DROP INDEX IF EXISTS idx_api_keys_key; -DROP TABLE IF EXISTS api_keys; \ No newline at end of file +DROP TABLE IF EXISTS api_keys; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250302220732_api_key_auth.up.sql b/backend/resources/migrations/sqlite/20250302220732_api_key_auth.up.sql index 3e27cb83..36a4ecc3 100644 --- a/backend/resources/migrations/sqlite/20250302220732_api_key_auth.up.sql +++ b/backend/resources/migrations/sqlite/20250302220732_api_key_auth.up.sql @@ -1,3 +1,5 @@ +PRAGMA foreign_keys=OFF; +BEGIN; CREATE TABLE api_keys ( id TEXT PRIMARY KEY, name TEXT NOT NULL, @@ -9,4 +11,6 @@ CREATE TABLE api_keys ( user_id TEXT REFERENCES users(id) ON DELETE CASCADE ); -CREATE INDEX idx_api_keys_key ON api_keys(key); \ No newline at end of file +CREATE INDEX idx_api_keys_key ON api_keys(key); +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250320171311_user_locale.down.sql b/backend/resources/migrations/sqlite/20250320171311_user_locale.down.sql index 6686c139..2f820fdf 100644 --- a/backend/resources/migrations/sqlite/20250320171311_user_locale.down.sql +++ b/backend/resources/migrations/sqlite/20250320171311_user_locale.down.sql @@ -1 +1,5 @@ -ALTER TABLE users DROP COLUMN locale; \ No newline at end of file +PRAGMA foreign_keys=OFF; +BEGIN; +ALTER TABLE users DROP COLUMN locale; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250320171311_user_locale.up.sql b/backend/resources/migrations/sqlite/20250320171311_user_locale.up.sql index 99644e0c..7662a65f 100644 --- a/backend/resources/migrations/sqlite/20250320171311_user_locale.up.sql +++ b/backend/resources/migrations/sqlite/20250320171311_user_locale.up.sql @@ -1 +1,5 @@ -ALTER TABLE users ADD COLUMN locale TEXT; \ No newline at end of file +PRAGMA foreign_keys=OFF; +BEGIN; +ALTER TABLE users ADD COLUMN locale TEXT; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250323184520_oidc_refresh_tokens.down.sql b/backend/resources/migrations/sqlite/20250323184520_oidc_refresh_tokens.down.sql index a81b71af..b5404270 100644 --- a/backend/resources/migrations/sqlite/20250323184520_oidc_refresh_tokens.down.sql +++ b/backend/resources/migrations/sqlite/20250323184520_oidc_refresh_tokens.down.sql @@ -1,2 +1,6 @@ +PRAGMA foreign_keys=OFF; +BEGIN; DROP INDEX IF EXISTS idx_oidc_refresh_tokens_token; -DROP TABLE IF EXISTS oidc_refresh_tokens; \ No newline at end of file +DROP TABLE IF EXISTS oidc_refresh_tokens; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250323184520_oidc_refresh_tokens.up.sql b/backend/resources/migrations/sqlite/20250323184520_oidc_refresh_tokens.up.sql index 5c3c66c2..ccd56c4c 100644 --- a/backend/resources/migrations/sqlite/20250323184520_oidc_refresh_tokens.up.sql +++ b/backend/resources/migrations/sqlite/20250323184520_oidc_refresh_tokens.up.sql @@ -1,3 +1,5 @@ +PRAGMA foreign_keys=OFF; +BEGIN; CREATE TABLE oidc_refresh_tokens ( id TEXT NOT NULL PRIMARY KEY, created_at DATETIME, @@ -8,4 +10,6 @@ CREATE TABLE oidc_refresh_tokens ( client_id TEXT NOT NULL REFERENCES oidc_clients(id) ON DELETE CASCADE ); -CREATE INDEX idx_oidc_refresh_tokens_token ON oidc_refresh_tokens(token); \ No newline at end of file +CREATE INDEX idx_oidc_refresh_tokens_token ON oidc_refresh_tokens(token); +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250403082322_audit_logs_indexes.down.sql b/backend/resources/migrations/sqlite/20250403082322_audit_logs_indexes.down.sql index fa8058b6..89a729e1 100644 --- a/backend/resources/migrations/sqlite/20250403082322_audit_logs_indexes.down.sql +++ b/backend/resources/migrations/sqlite/20250403082322_audit_logs_indexes.down.sql @@ -1,3 +1,8 @@ +PRAGMA foreign_keys=OFF; +BEGIN; DROP INDEX IF EXISTS idx_audit_logs_event; DROP INDEX IF EXISTS idx_audit_logs_user_id; DROP INDEX IF EXISTS idx_audit_logs_client_name; + +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250403082322_audit_logs_indexes.up.sql b/backend/resources/migrations/sqlite/20250403082322_audit_logs_indexes.up.sql index a9011ba2..bffca904 100644 --- a/backend/resources/migrations/sqlite/20250403082322_audit_logs_indexes.up.sql +++ b/backend/resources/migrations/sqlite/20250403082322_audit_logs_indexes.up.sql @@ -1,3 +1,8 @@ +PRAGMA foreign_keys=OFF; +BEGIN; CREATE INDEX idx_audit_logs_event ON audit_logs(event); CREATE INDEX idx_audit_logs_user_id ON audit_logs(user_id); CREATE INDEX idx_audit_logs_client_name ON audit_logs((json_extract(data, '$.clientName'))); + +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250408120918_app_config_cols.down.sql b/backend/resources/migrations/sqlite/20250408120918_app_config_cols.down.sql index db269245..5a0ef1f1 100644 --- a/backend/resources/migrations/sqlite/20250408120918_app_config_cols.down.sql +++ b/backend/resources/migrations/sqlite/20250408120918_app_config_cols.down.sql @@ -1,4 +1,9 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE app_config_variables ADD type VARCHAR(20) NOT NULL,; ALTER TABLE app_config_variables ADD is_public BOOLEAN DEFAULT FALSE NOT NULL,; ALTER TABLE app_config_variables ADD is_internal BOOLEAN DEFAULT FALSE NOT NULL,; ALTER TABLE app_config_variables ADD default_value TEXT; + +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250408120918_app_config_cols.up.sql b/backend/resources/migrations/sqlite/20250408120918_app_config_cols.up.sql index e3827f0c..542a8b20 100644 --- a/backend/resources/migrations/sqlite/20250408120918_app_config_cols.up.sql +++ b/backend/resources/migrations/sqlite/20250408120918_app_config_cols.up.sql @@ -1,4 +1,8 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE app_config_variables DROP type; ALTER TABLE app_config_variables DROP is_public; ALTER TABLE app_config_variables DROP is_internal; -ALTER TABLE app_config_variables DROP default_value; \ No newline at end of file +ALTER TABLE app_config_variables DROP default_value; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250412000000_add_user_disabled_field.down.sql b/backend/resources/migrations/sqlite/20250412000000_add_user_disabled_field.down.sql index 3a020820..010af5d1 100644 --- a/backend/resources/migrations/sqlite/20250412000000_add_user_disabled_field.down.sql +++ b/backend/resources/migrations/sqlite/20250412000000_add_user_disabled_field.down.sql @@ -1,4 +1,8 @@ +PRAGMA foreign_keys=OFF; +BEGIN; DROP INDEX idx_users_disabled; ALTER TABLE users -DROP COLUMN disabled; \ No newline at end of file +DROP COLUMN disabled; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250412000000_add_user_disabled_field.up.sql b/backend/resources/migrations/sqlite/20250412000000_add_user_disabled_field.up.sql index 989a4772..c04eb01a 100644 --- a/backend/resources/migrations/sqlite/20250412000000_add_user_disabled_field.up.sql +++ b/backend/resources/migrations/sqlite/20250412000000_add_user_disabled_field.up.sql @@ -1,2 +1,6 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE users -ADD COLUMN disabled NUMERIC DEFAULT FALSE NOT NULL; \ No newline at end of file +ADD COLUMN disabled NUMERIC DEFAULT FALSE NOT NULL; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250417120000_add_expiration_email_sent_to_api_keys.down.sql b/backend/resources/migrations/sqlite/20250417120000_add_expiration_email_sent_to_api_keys.down.sql index 16532c3a..dc5f43e3 100644 --- a/backend/resources/migrations/sqlite/20250417120000_add_expiration_email_sent_to_api_keys.down.sql +++ b/backend/resources/migrations/sqlite/20250417120000_add_expiration_email_sent_to_api_keys.down.sql @@ -1,2 +1,6 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE api_keys -DROP COLUMN expiration_email_sent; \ No newline at end of file +DROP COLUMN expiration_email_sent; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250417120000_add_expiration_email_sent_to_api_keys.up.sql b/backend/resources/migrations/sqlite/20250417120000_add_expiration_email_sent_to_api_keys.up.sql index 8f63aba6..5507bc64 100644 --- a/backend/resources/migrations/sqlite/20250417120000_add_expiration_email_sent_to_api_keys.up.sql +++ b/backend/resources/migrations/sqlite/20250417120000_add_expiration_email_sent_to_api_keys.up.sql @@ -1,2 +1,6 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE api_keys -ADD COLUMN expiration_email_sent BOOLEAN NOT NULL DEFAULT 0; \ No newline at end of file +ADD COLUMN expiration_email_sent BOOLEAN NOT NULL DEFAULT 0; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250421221059_add_device_codes.down.sql b/backend/resources/migrations/sqlite/20250421221059_add_device_codes.down.sql index cafa847c..895425e5 100644 --- a/backend/resources/migrations/sqlite/20250421221059_add_device_codes.down.sql +++ b/backend/resources/migrations/sqlite/20250421221059_add_device_codes.down.sql @@ -1 +1,5 @@ -DROP TABLE oidc_device_codes; \ No newline at end of file +PRAGMA foreign_keys=OFF; +BEGIN; +DROP TABLE oidc_device_codes; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250421221059_add_device_codes.up.sql b/backend/resources/migrations/sqlite/20250421221059_add_device_codes.up.sql index 9ba058b3..b86511da 100644 --- a/backend/resources/migrations/sqlite/20250421221059_add_device_codes.up.sql +++ b/backend/resources/migrations/sqlite/20250421221059_add_device_codes.up.sql @@ -1,3 +1,5 @@ +PRAGMA foreign_keys=OFF; +BEGIN; CREATE TABLE oidc_device_codes ( id TEXT NOT NULL PRIMARY KEY, @@ -9,4 +11,6 @@ CREATE TABLE oidc_device_codes is_authorized BOOLEAN NOT NULL DEFAULT FALSE, user_id TEXT REFERENCES users ON DELETE CASCADE, client_id TEXT NOT NULL REFERENCES oidc_clients ON DELETE CASCADE -); \ No newline at end of file +); +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250601204251_clear_default_app_config_variables.down.sql b/backend/resources/migrations/sqlite/20250601204251_clear_default_app_config_variables.down.sql index 69379243..f8e19576 100644 --- a/backend/resources/migrations/sqlite/20250601204251_clear_default_app_config_variables.down.sql +++ b/backend/resources/migrations/sqlite/20250601204251_clear_default_app_config_variables.down.sql @@ -1 +1 @@ --- No rollback is needed for this migration. \ No newline at end of file +-- No-op \ No newline at end of file diff --git a/backend/resources/migrations/sqlite/20250601204251_clear_default_app_config_variables.up.sql b/backend/resources/migrations/sqlite/20250601204251_clear_default_app_config_variables.up.sql index b39ea652..3682ed36 100644 --- a/backend/resources/migrations/sqlite/20250601204251_clear_default_app_config_variables.up.sql +++ b/backend/resources/migrations/sqlite/20250601204251_clear_default_app_config_variables.up.sql @@ -1 +1,5 @@ -DELETE FROM app_config_variables WHERE value = ''; \ No newline at end of file +PRAGMA foreign_keys=OFF; +BEGIN; +DELETE FROM app_config_variables WHERE value = ''; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250609202611_client_credentials.down.sql b/backend/resources/migrations/sqlite/20250609202611_client_credentials.down.sql index 41aab182..e543a208 100644 --- a/backend/resources/migrations/sqlite/20250609202611_client_credentials.down.sql +++ b/backend/resources/migrations/sqlite/20250609202611_client_credentials.down.sql @@ -1 +1,6 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE oidc_clients DROP COLUMN credentials; + +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250609202611_client_credentials.up.sql b/backend/resources/migrations/sqlite/20250609202611_client_credentials.up.sql index 26089724..bb2f4ee9 100644 --- a/backend/resources/migrations/sqlite/20250609202611_client_credentials.up.sql +++ b/backend/resources/migrations/sqlite/20250609202611_client_credentials.up.sql @@ -1 +1,6 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE oidc_clients ADD COLUMN credentials TEXT NULL; + +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250619115053_add_country_index.down.sql b/backend/resources/migrations/sqlite/20250619115053_add_country_index.down.sql index 70d390bb..87c67766 100644 --- a/backend/resources/migrations/sqlite/20250619115053_add_country_index.down.sql +++ b/backend/resources/migrations/sqlite/20250619115053_add_country_index.down.sql @@ -1 +1,5 @@ -DROP INDEX idx_audit_logs_country; \ No newline at end of file +PRAGMA foreign_keys=OFF; +BEGIN; +DROP INDEX idx_audit_logs_country; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250619115053_add_country_index.up.sql b/backend/resources/migrations/sqlite/20250619115053_add_country_index.up.sql index fa92172c..e0f362a6 100644 --- a/backend/resources/migrations/sqlite/20250619115053_add_country_index.up.sql +++ b/backend/resources/migrations/sqlite/20250619115053_add_country_index.up.sql @@ -1 +1,5 @@ -CREATE INDEX idx_audit_logs_country ON audit_logs(country); \ No newline at end of file +PRAGMA foreign_keys=OFF; +BEGIN; +CREATE INDEX idx_audit_logs_country ON audit_logs(country); +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250622151258_add_signup_tokens.down.sql b/backend/resources/migrations/sqlite/20250622151258_add_signup_tokens.down.sql index 3ea627f1..f905a2d1 100644 --- a/backend/resources/migrations/sqlite/20250622151258_add_signup_tokens.down.sql +++ b/backend/resources/migrations/sqlite/20250622151258_add_signup_tokens.down.sql @@ -1,3 +1,7 @@ +PRAGMA foreign_keys=OFF; +BEGIN; DROP INDEX IF EXISTS idx_signup_tokens_expires_at; DROP INDEX IF EXISTS idx_signup_tokens_token; -DROP TABLE IF EXISTS signup_tokens; \ No newline at end of file +DROP TABLE IF EXISTS signup_tokens; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250622151258_add_signup_tokens.up.sql b/backend/resources/migrations/sqlite/20250622151258_add_signup_tokens.up.sql index e0926113..ae859b33 100644 --- a/backend/resources/migrations/sqlite/20250622151258_add_signup_tokens.up.sql +++ b/backend/resources/migrations/sqlite/20250622151258_add_signup_tokens.up.sql @@ -1,3 +1,5 @@ +PRAGMA foreign_keys=OFF; +BEGIN; CREATE TABLE signup_tokens ( id TEXT NOT NULL PRIMARY KEY, created_at DATETIME NOT NULL, @@ -8,4 +10,6 @@ CREATE TABLE signup_tokens ( ); CREATE INDEX idx_signup_tokens_token ON signup_tokens(token); -CREATE INDEX idx_signup_tokens_expires_at ON signup_tokens(expires_at); \ No newline at end of file +CREATE INDEX idx_signup_tokens_expires_at ON signup_tokens(expires_at); +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250628000000_audit_logs_ip_null.down.sql b/backend/resources/migrations/sqlite/20250628000000_audit_logs_ip_null.down.sql index 53803e77..0f91e371 100644 --- a/backend/resources/migrations/sqlite/20250628000000_audit_logs_ip_null.down.sql +++ b/backend/resources/migrations/sqlite/20250628000000_audit_logs_ip_null.down.sql @@ -1,3 +1,5 @@ +PRAGMA foreign_keys=OFF; +BEGIN; -- Re-create the table with non-nullable ip_address -- We then move the data and rename the table CREATE TABLE audit_logs_new @@ -28,3 +30,6 @@ CREATE INDEX idx_audit_logs_user_id ON audit_logs(user_id); CREATE INDEX idx_audit_logs_user_agent ON audit_logs(user_agent); CREATE INDEX idx_audit_logs_client_name ON audit_logs((json_extract(data, '$.clientName'))); CREATE INDEX idx_audit_logs_country ON audit_logs(country); + +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250628000000_audit_logs_ip_null.up.sql b/backend/resources/migrations/sqlite/20250628000000_audit_logs_ip_null.up.sql index edbeca9a..a44a0f94 100644 --- a/backend/resources/migrations/sqlite/20250628000000_audit_logs_ip_null.up.sql +++ b/backend/resources/migrations/sqlite/20250628000000_audit_logs_ip_null.up.sql @@ -1,3 +1,5 @@ +PRAGMA foreign_keys=OFF; +BEGIN; -- Re-create the table with nullable ip_address -- We then move the data and rename the table CREATE TABLE audit_logs_new @@ -28,3 +30,6 @@ CREATE INDEX idx_audit_logs_user_id ON audit_logs(user_id); CREATE INDEX idx_audit_logs_user_agent ON audit_logs(user_agent); CREATE INDEX idx_audit_logs_client_name ON audit_logs((json_extract(data, '$.clientName'))); CREATE INDEX idx_audit_logs_country ON audit_logs(country); + +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250630000000_kv_table.down.sql b/backend/resources/migrations/sqlite/20250630000000_kv_table.down.sql index 7ec25a79..ecc9d767 100644 --- a/backend/resources/migrations/sqlite/20250630000000_kv_table.down.sql +++ b/backend/resources/migrations/sqlite/20250630000000_kv_table.down.sql @@ -1 +1,6 @@ +PRAGMA foreign_keys=OFF; +BEGIN; DROP TABLE kv; + +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250630000000_kv_table.up.sql b/backend/resources/migrations/sqlite/20250630000000_kv_table.up.sql index fae1de92..bfdc428a 100644 --- a/backend/resources/migrations/sqlite/20250630000000_kv_table.up.sql +++ b/backend/resources/migrations/sqlite/20250630000000_kv_table.up.sql @@ -1,6 +1,11 @@ +PRAGMA foreign_keys=OFF; +BEGIN; -- The "kv" tables contains miscellaneous key-value pairs CREATE TABLE kv ( "key" TEXT NOT NULL PRIMARY KEY, "value" TEXT NOT NULL ); + +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250705000000_normalize.down.sql b/backend/resources/migrations/sqlite/20250705000000_normalize.down.sql index 0813dbe8..f8e19576 100644 --- a/backend/resources/migrations/sqlite/20250705000000_normalize.down.sql +++ b/backend/resources/migrations/sqlite/20250705000000_normalize.down.sql @@ -1 +1 @@ --- No-op +-- No-op \ No newline at end of file diff --git a/backend/resources/migrations/sqlite/20250705000000_normalize.up.sql b/backend/resources/migrations/sqlite/20250705000000_normalize.up.sql index 27c5700f..793ae8f9 100644 --- a/backend/resources/migrations/sqlite/20250705000000_normalize.up.sql +++ b/backend/resources/migrations/sqlite/20250705000000_normalize.up.sql @@ -1,3 +1,5 @@ +PRAGMA foreign_keys=OFF; +BEGIN; -- Normalize (form NFC) all existing values in the database UPDATE api_keys SET name = normalize(name, 'nfc'), @@ -23,3 +25,6 @@ UPDATE users SET UPDATE user_groups SET friendly_name = normalize(friendly_name, 'nfc'), "name" = normalize("name", 'nfc'); + +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250810144214_apps_dashboard.down.sql b/backend/resources/migrations/sqlite/20250810144214_apps_dashboard.down.sql index 1267c6ef..90141c55 100644 --- a/backend/resources/migrations/sqlite/20250810144214_apps_dashboard.down.sql +++ b/backend/resources/migrations/sqlite/20250810144214_apps_dashboard.down.sql @@ -1,3 +1,7 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE oidc_clients DROP COLUMN launch_url; -ALTER TABLE user_authorized_oidc_clients DROP COLUMN created_at; \ No newline at end of file +ALTER TABLE user_authorized_oidc_clients DROP COLUMN created_at; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250810144214_apps_dashboard.up.sql b/backend/resources/migrations/sqlite/20250810144214_apps_dashboard.up.sql index d5e3085c..1299d746 100644 --- a/backend/resources/migrations/sqlite/20250810144214_apps_dashboard.up.sql +++ b/backend/resources/migrations/sqlite/20250810144214_apps_dashboard.up.sql @@ -1,3 +1,5 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE oidc_clients ADD COLUMN launch_url TEXT; CREATE TABLE user_authorized_oidc_clients_new @@ -14,3 +16,6 @@ SELECT scope, user_id, client_id, unixepoch() FROM user_authorized_oidc_clients; DROP TABLE user_authorized_oidc_clients; ALTER TABLE user_authorized_oidc_clients_new RENAME TO user_authorized_oidc_clients; + +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250814121300_requires_reauthentication.down.sql b/backend/resources/migrations/sqlite/20250814121300_requires_reauthentication.down.sql index 2b669840..acf2dd50 100644 --- a/backend/resources/migrations/sqlite/20250814121300_requires_reauthentication.down.sql +++ b/backend/resources/migrations/sqlite/20250814121300_requires_reauthentication.down.sql @@ -1,3 +1,7 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE oidc_clients DROP COLUMN requires_reauthentication; DROP INDEX IF EXISTS idx_reauthentication_tokens_token; -DROP TABLE IF EXISTS reauthentication_tokens; \ No newline at end of file +DROP TABLE IF EXISTS reauthentication_tokens; +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250814121300_requires_reauthentication.up.sql b/backend/resources/migrations/sqlite/20250814121300_requires_reauthentication.up.sql index e5691bc7..d566adb1 100644 --- a/backend/resources/migrations/sqlite/20250814121300_requires_reauthentication.up.sql +++ b/backend/resources/migrations/sqlite/20250814121300_requires_reauthentication.up.sql @@ -1,3 +1,5 @@ +PRAGMA foreign_keys=OFF; +BEGIN; ALTER TABLE oidc_clients ADD COLUMN requires_reauthentication BOOLEAN NOT NULL DEFAULT FALSE; CREATE TABLE reauthentication_tokens ( @@ -8,4 +10,6 @@ CREATE TABLE reauthentication_tokens ( user_id TEXT NOT NULL REFERENCES users ON DELETE CASCADE ); -CREATE INDEX idx_reauthentication_tokens_token ON reauthentication_tokens(token); \ No newline at end of file +CREATE INDEX idx_reauthentication_tokens_token ON reauthentication_tokens(token); +COMMIT; +PRAGMA foreign_keys=ON; diff --git a/backend/resources/migrations/sqlite/20250822000000_foreign_keys_improvements.up.sql b/backend/resources/migrations/sqlite/20250822000000_foreign_keys_improvements.up.sql index 532130b6..6987585c 100644 --- a/backend/resources/migrations/sqlite/20250822000000_foreign_keys_improvements.up.sql +++ b/backend/resources/migrations/sqlite/20250822000000_foreign_keys_improvements.up.sql @@ -1,4 +1,6 @@ PRAGMA foreign_keys=OFF; +BEGIN; +PRAGMA foreign_keys=OFF; --------------------------- -- Delete all orphaned rows --------------------------- @@ -174,4 +176,6 @@ DROP TABLE webauthn_credentials; ALTER TABLE webauthn_credentials_new RENAME TO webauthn_credentials; PRAGMA foreign_keys=ON; -PRAGMA foreign_key_check; \ No newline at end of file +PRAGMA foreign_key_check; +COMMIT; +PRAGMA foreign_keys=ON;