From 914a946057b94a9b33e4401e48d2789e4854b6c7 Mon Sep 17 00:00:00 2001 From: Nicholas Cristofaro Date: Thu, 4 Jan 2024 14:11:55 +0000 Subject: [PATCH] is: Add user console preferences migration --- .../20240103000001_console_preferences.down.sql | 15 +++++++++++++++ .../20240103000001_console_preferences.up.sql | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 pkg/identityserver/store/migrations/20240103000001_console_preferences.down.sql create mode 100644 pkg/identityserver/store/migrations/20240103000001_console_preferences.up.sql diff --git a/pkg/identityserver/store/migrations/20240103000001_console_preferences.down.sql b/pkg/identityserver/store/migrations/20240103000001_console_preferences.down.sql new file mode 100644 index 00000000000..fd71d4a2563 --- /dev/null +++ b/pkg/identityserver/store/migrations/20240103000001_console_preferences.down.sql @@ -0,0 +1,15 @@ +ALTER TABLE users DROP COLUMN IF EXISTS console_preferences CASCADE; + +--bun:split +CREATE OR REPLACE VIEW user_accounts AS +SELECT + acc.id AS account_id, + acc.created_at AS account_created_at, + acc.updated_at AS account_updated_at, + acc.deleted_at AS account_deleted_at, + acc.uid AS account_uid, + usr.* +FROM + accounts acc + JOIN users usr ON usr.id = acc.account_id + AND acc.account_type = 'user'; diff --git a/pkg/identityserver/store/migrations/20240103000001_console_preferences.up.sql b/pkg/identityserver/store/migrations/20240103000001_console_preferences.up.sql new file mode 100644 index 00000000000..cbf83c5f2c3 --- /dev/null +++ b/pkg/identityserver/store/migrations/20240103000001_console_preferences.up.sql @@ -0,0 +1,16 @@ +ALTER TABLE users +ADD COLUMN IF NOT EXISTS console_preferences bytea; + +--bun:split +CREATE OR REPLACE VIEW user_accounts AS +SELECT + acc.id AS account_id, + acc.created_at AS account_created_at, + acc.updated_at AS account_updated_at, + acc.deleted_at AS account_deleted_at, + acc.uid AS account_uid, + usr.* +FROM + accounts acc + JOIN users usr ON usr.id = acc.account_id + AND acc.account_type = 'user';