1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-28 03:51:23 +01:00

#453 PostgreSQL - Views (#560)

* PostgreSQL initial commit of translation from SQL Server to PostgreSQL

* snake_case added.
set search path for schema.  schema qualified name no longer needed for creation and access of functions.

* Table DDL for PostgreSQL

* Rename User.sql to user.sql

* PostgreSQL views, 
snake_case column fix for user_create, 
rename of users.sql file to lowercase
This commit is contained in:
Papina 2019-09-12 21:59:07 +10:00 committed by Kyle Spearrin
parent ba6baa3caa
commit 79ffda0377
15 changed files with 110 additions and 1 deletions

View File

@ -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,

View File

@ -0,0 +1,6 @@
CREATE VIEW cipher_view
AS
SELECT
*
FROM
cipher;

View File

@ -0,0 +1,6 @@
CREATE VIEW collection_view
AS
SELECT
*
FROM
collection;

View File

@ -0,0 +1,6 @@
CREATE VIEW device_view
AS
SELECT
*
FROM
device;

View File

@ -0,0 +1,6 @@
CREATE VIEW event_view
AS
SELECT
*
FROM
event;

View File

@ -0,0 +1,6 @@
CREATE VIEW folder_view
AS
SELECT
*
FROM
folder;

View File

@ -0,0 +1,6 @@
CREATE VIEW grant_view
AS
SELECT
*
FROM
"grant";

View File

@ -0,0 +1,6 @@
CREATE VIEW group_view
AS
SELECT
*
FROM
"group";

View File

@ -0,0 +1,6 @@
CREATE VIEW installation_view
AS
SELECT
*
FROM
installation;

View File

@ -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;

View File

@ -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;

View File

@ -0,0 +1,6 @@
CREATE VIEW organization_user_view
AS
SELECT
*
FROM
organization_user;

View File

@ -0,0 +1,6 @@
CREATE VIEW organization_view
AS
SELECT
*
FROM
organization;

View File

@ -0,0 +1,6 @@
CREATE VIEW transaction_view
AS
SELECT
*
FROM
transaction;