diff --git a/src/Sql/PostgreSQL/Functions/user_create.sql b/src/Sql/PostgreSQL/Functions/user_create.sql index 1b90e4c960..d6cd7f5d93 100644 --- a/src/Sql/PostgreSQL/Functions/user_create.sql +++ b/src/Sql/PostgreSQL/Functions/user_create.sql @@ -46,7 +46,7 @@ BEGIN culture, security_stamp, two_factor_providers, - two_factor_recoverycode, + two_factor_recovery_code, equivalent_domains, excluded_global_equivalent_domains, account_revision_date, diff --git a/src/Sql/PostgreSQL/Tables/User.sql b/src/Sql/PostgreSQL/Tables/user.sql similarity index 100% rename from src/Sql/PostgreSQL/Tables/User.sql rename to src/Sql/PostgreSQL/Tables/user.sql diff --git a/src/Sql/PostgreSQL/Views/cipher_view.sql b/src/Sql/PostgreSQL/Views/cipher_view.sql new file mode 100644 index 0000000000..3a240fc3a1 --- /dev/null +++ b/src/Sql/PostgreSQL/Views/cipher_view.sql @@ -0,0 +1,6 @@ +CREATE VIEW cipher_view +AS +SELECT + * +FROM + cipher; \ No newline at end of file diff --git a/src/Sql/PostgreSQL/Views/collection_view.sql b/src/Sql/PostgreSQL/Views/collection_view.sql new file mode 100644 index 0000000000..cbc19f36a9 --- /dev/null +++ b/src/Sql/PostgreSQL/Views/collection_view.sql @@ -0,0 +1,6 @@ +CREATE VIEW collection_view +AS +SELECT + * +FROM + collection; \ No newline at end of file diff --git a/src/Sql/PostgreSQL/Views/device_view.sql b/src/Sql/PostgreSQL/Views/device_view.sql new file mode 100644 index 0000000000..1aa89d09b1 --- /dev/null +++ b/src/Sql/PostgreSQL/Views/device_view.sql @@ -0,0 +1,6 @@ +CREATE VIEW device_view +AS +SELECT + * +FROM + device; \ No newline at end of file diff --git a/src/Sql/PostgreSQL/Views/event_view.sql b/src/Sql/PostgreSQL/Views/event_view.sql new file mode 100644 index 0000000000..df687bcd35 --- /dev/null +++ b/src/Sql/PostgreSQL/Views/event_view.sql @@ -0,0 +1,6 @@ +CREATE VIEW event_view +AS +SELECT + * +FROM + event; \ No newline at end of file diff --git a/src/Sql/PostgreSQL/Views/folder_view.sql b/src/Sql/PostgreSQL/Views/folder_view.sql new file mode 100644 index 0000000000..506e1f8d39 --- /dev/null +++ b/src/Sql/PostgreSQL/Views/folder_view.sql @@ -0,0 +1,6 @@ +CREATE VIEW folder_view +AS +SELECT + * +FROM + folder; \ No newline at end of file diff --git a/src/Sql/PostgreSQL/Views/grant_view.sql b/src/Sql/PostgreSQL/Views/grant_view.sql new file mode 100644 index 0000000000..11e07ff0de --- /dev/null +++ b/src/Sql/PostgreSQL/Views/grant_view.sql @@ -0,0 +1,6 @@ +CREATE VIEW grant_view +AS +SELECT + * +FROM + "grant"; \ No newline at end of file diff --git a/src/Sql/PostgreSQL/Views/group_view.sql b/src/Sql/PostgreSQL/Views/group_view.sql new file mode 100644 index 0000000000..b1cb0a4f67 --- /dev/null +++ b/src/Sql/PostgreSQL/Views/group_view.sql @@ -0,0 +1,6 @@ +CREATE VIEW group_view +AS +SELECT + * +FROM + "group"; \ No newline at end of file diff --git a/src/Sql/PostgreSQL/Views/installation_view.sql b/src/Sql/PostgreSQL/Views/installation_view.sql new file mode 100644 index 0000000000..14d60e10b6 --- /dev/null +++ b/src/Sql/PostgreSQL/Views/installation_view.sql @@ -0,0 +1,6 @@ +CREATE VIEW installation_view +AS +SELECT + * +FROM + installation; \ No newline at end of file diff --git a/src/Sql/PostgreSQL/Views/organization_user_organization_details_view.sql b/src/Sql/PostgreSQL/Views/organization_user_organization_details_view.sql new file mode 100644 index 0000000000..44afbaa684 --- /dev/null +++ b/src/Sql/PostgreSQL/Views/organization_user_organization_details_view.sql @@ -0,0 +1,25 @@ +CREATE VIEW organization_user_organization_details_view +AS +SELECT + ou.user_id, + ou.organization_id, + o.name, + o.enabled, + o.use_groups, + o.use_directory, + o.use_events, + o.use_totp, + o.use_2fa, + o.use_api, + o.self_host, + o.users_get_premium, + o.seats, + o.max_collections, + o.max_storage_gb, + ou.key, + ou.status, + ou.type +FROM + organization_user ou +INNER JOIN + organization o ON o.id = ou.organization_id; \ No newline at end of file diff --git a/src/Sql/PostgreSQL/Views/organization_user_user_details_view.sql b/src/Sql/PostgreSQL/Views/organization_user_user_details_view.sql new file mode 100644 index 0000000000..70c05ccf0d --- /dev/null +++ b/src/Sql/PostgreSQL/Views/organization_user_user_details_view.sql @@ -0,0 +1,18 @@ +CREATE VIEW organization_user_user_details_view +AS +SELECT + ou.id, + ou.user_id, + ou.organization_id, + u.name, + coalesce(u.email, ou.email) email, + u.two_factor_providers, + u.premium, + ou.status, + ou.type, + ou.access_all, + ou.external_id +FROM + organization_user ou +LEFT JOIN + "user" u ON U.id = ou.user_id; \ No newline at end of file diff --git a/src/Sql/PostgreSQL/Views/organization_user_view.sql b/src/Sql/PostgreSQL/Views/organization_user_view.sql new file mode 100644 index 0000000000..ba9df2fd8f --- /dev/null +++ b/src/Sql/PostgreSQL/Views/organization_user_view.sql @@ -0,0 +1,6 @@ +CREATE VIEW organization_user_view +AS +SELECT + * +FROM + organization_user; \ No newline at end of file diff --git a/src/Sql/PostgreSQL/Views/organization_view.sql b/src/Sql/PostgreSQL/Views/organization_view.sql new file mode 100644 index 0000000000..deeb0196d9 --- /dev/null +++ b/src/Sql/PostgreSQL/Views/organization_view.sql @@ -0,0 +1,6 @@ +CREATE VIEW organization_view +AS +SELECT + * +FROM + organization; \ No newline at end of file diff --git a/src/Sql/PostgreSQL/Views/transaction_view.sql b/src/Sql/PostgreSQL/Views/transaction_view.sql new file mode 100644 index 0000000000..c93cfc965a --- /dev/null +++ b/src/Sql/PostgreSQL/Views/transaction_view.sql @@ -0,0 +1,6 @@ +CREATE VIEW transaction_view +AS +SELECT + * +FROM + transaction; \ No newline at end of file