1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-26 12:55:17 +01:00

delete old postgres work that was never used

This commit is contained in:
Kyle Spearrin 2021-07-12 09:58:36 -04:00
parent 1941ba0a41
commit 9bb29e08a9
42 changed files with 0 additions and 875 deletions

View File

@ -1,105 +0,0 @@
DROP FUNCTION IF EXISTS user_create(UUID,VARCHAR,VARCHAR,BOOLEAN,VARCHAR,VARCHAR,VARCHAR,VARCHAR,TEXT,VARCHAR,TEXT,TEXT,TIMESTAMPTZ,TEXT,TEXT,TEXT,BOOLEAN,TIMESTAMPTZ,TIMESTAMPTZ,BIGINT,SMALLINT,SMALLINT,VARCHAR,VARCHAR,VARCHAR,SMALLINT,INT,TIMESTAMPTZ,TIMESTAMPTZ);
CREATE OR REPLACE FUNCTION user_create
(
_id UUID,
_name VARCHAR,
_email VARCHAR,
_email_verified BOOLEAN,
_master_password VARCHAR,
_master_password_hint VARCHAR,
_culture VARCHAR,
_security_stamp VARCHAR,
_two_factor_providers TEXT,
_two_factor_recovery_code VARCHAR,
_equivalent_domains TEXT,
_excluded_global_equivalent_domains TEXT,
_account_revision_date TIMESTAMPTZ,
_key TEXT,
_public_key TEXT,
_private_key TEXT,
_premium BOOLEAN,
_premium_expiration_date TIMESTAMPTZ,
_renewal_reminder_date TIMESTAMPTZ,
_storage BIGINT,
_max_storage_gb SMALLINT,
_gateway SMALLINT,
_gateway_customer_id VARCHAR,
_gateway_subscription_id VARCHAR,
_license_key VARCHAR,
_kdf SMALLINT,
_kdf_iterations INT,
_creation_date TIMESTAMPTZ,
_revision_date TIMESTAMPTZ
)
RETURNS VOID
LANGUAGE 'plpgsql'
AS
$$
BEGIN
INSERT INTO "user"
(
id,
name,
email,
email_verified,
master_password,
master_password_hint,
culture,
security_stamp,
two_factor_providers,
two_factor_recovery_code,
equivalent_domains,
excluded_global_equivalent_domains,
account_revision_date,
key,
public_key,
private_key,
premium,
premium_expiration_date,
renewal_reminder_date,
storage,
max_storage_gb,
gateway,
gateway_customer_id,
gateway_subscription_id,
license_key,
kdf,
kdf_iterations,
creation_date,
revision_date
)
VALUES
(
_id,
_name,
_email,
_email_verified,
_master_password,
_master_password_hint,
_culture,
_security_stamp,
_two_factor_providers,
_two_factor_recovery_code,
_equivalent_domains,
_excluded_global_equivalent_domains,
_account_revision_date,
_key,
_public_key,
_private_key,
_premium,
_premium_expiration_date,
_renewal_reminder_date,
_storage,
_max_storage_gb,
_gateway,
_gateway_customer_id,
_gateway_subscription_id,
_license_key,
_kdf,
_kdf_iterations,
_creation_date,
_revision_date
);
END
$$

View File

@ -1,71 +0,0 @@
DROP FUNCTION IF EXISTS user_delete_by_id (UUID);
CREATE OR REPLACE FUNCTION user_delete_by_id
(
_id UUID
)
RETURNS VOID
LANGUAGE 'plpgsql'
AS
$BODY$
BEGIN
-- functions dont support commit/rollback transactions, only v11+ procedures can do this
DELETE FROM
cipher
WHERE
user_id = _id;
-- Delete folders
DELETE FROM
folder
WHERE
user_id = _id;
-- Delete devices
DELETE FROM
device
WHERE
user_id = _id;
-- Delete collection users
DELETE FROM
collection_user CU
USING
organization_user OU
WHERE
OU.id = CU.organization_user_id
AND
OU.user_id = _id;
-- Delete group users
DELETE FROM
group_user GU
USING
organization_user OU
WHERE
OU.id = GU.organization_user_id
AND
OU.user_id = _id;
-- Delete organization users
DELETE
FROM
organization_user
WHERE
user_id = _id;
-- Delete U2F logins
DELETE
FROM
u2f
WHERE
user_id = _id;
-- Finally, delete the user
DELETE
FROM
"user"
WHERE
id = _id;
END
$BODY$

View File

@ -1,20 +0,0 @@
DROP FUNCTION IF EXISTS user_read_by_email (VARCHAR);
CREATE OR REPLACE FUNCTION user_read_by_email
(
_email VARCHAR
)
RETURNS SETOF user_view
LANGUAGE 'plpgsql'
AS
$BODY$
BEGIN
RETURN QUERY
SELECT
*
FROM
user_view
WHERE
email = _email;
END
$BODY$

View File

@ -1,20 +0,0 @@
DROP FUNCTION IF EXISTS user_read_by_id;
CREATE OR REPLACE FUNCTION user_read_by_id
(
_id uuid
)
RETURNS SETOF user_view
LANGUAGE 'plpgsql'
AS
$BODY$
BEGIN
RETURN QUERY
SELECT
*
FROM
user_view
WHERE
id = _id;
END
$BODY$;

View File

@ -1,30 +0,0 @@
DROP FUNCTION IF EXISTS user_search (VARCHAR,INT,INT);
CREATE OR REPLACE FUNCTION user_search
(
_email VARCHAR,
_skip INT DEFAULT 0,
_take INT DEFAULT 25
)
RETURNS SETOF user_view
LANGUAGE 'plpgsql'
AS
$BODY$
DECLARE
email_like_search VARCHAR(261) = _email || '%';
BEGIN
RETURN QUERY
SELECT
*
FROM
user_view
WHERE
email IS NULL
OR
email LIKE email_like_search
ORDER BY email ASC
OFFSET _skip ROWS
FETCH NEXT _take ROWS only;
end
$BODY$

View File

@ -1,75 +0,0 @@
DROP FUNCTION IF EXISTS user_update(UUID,VARCHAR,VARCHAR,BOOLEAN,VARCHAR,VARCHAR,VARCHAR,VARCHAR,TEXT,VARCHAR,TEXT,TEXT,TIMESTAMPTZ,TEXT,TEXT,TEXT,BOOLEAN,TIMESTAMPTZ,TIMESTAMPTZ,BIGINT,SMALLINT,SMALLINT,VARCHAR,VARCHAR,VARCHAR,SMALLINT,INT,TIMESTAMPTZ,TIMESTAMPTZ)
CREATE OR REPLACE FUNCTION user_update
(
_id UUID,
_name VARCHAR,
_email VARCHAR,
_email_verified BOOLEAN,
_master_password VARCHAR,
_master_password_hint VARCHAR,
_culture VARCHAR,
_security_stamp VARCHAR,
_two_factor_providers TEXT,
_two_factor_recovery_code VARCHAR,
_equivalent_domains TEXT,
_excluded_global_equivalent_domains TEXT,
_account_revision_date TIMESTAMPTZ,
_key TEXT,
_public_key TEXT,
_private_key TEXT ,
_premium BOOLEAN,
_premium_expiration_date TIMESTAMPTZ,
_renewal_reminder_date TIMESTAMPTZ,
_storage BIGINT,
_max_storage_gb SMALLINT,
_gateway SMALLINT,
_gateway_customer_id VARCHAR,
_gateway_subscription_id VARCHAR,
_license_key VARCHAR,
_kdf SMALLINT,
_kdf_iterations INT,
_creation_date TIMESTAMPTZ,
_revision_date TIMESTAMPTZ
)
RETURNS VOID
LANGUAGE plpgsql
AS
$$
begin
UPDATE
"user"
SET name = _name,
email = _email,
email_verified = _email_verified,
master_password = _master_password,
master_password_hint = _master_password_hint,
culture = _culture,
security_stamp = _security_stamp,
two_factor_providers = _two_factor_providers,
two_factor_recovery_code = _two_factor_recovery_code,
equivalent_domains = _equivalent_domains,
excluded_global_equivalent_domains = _excluded_global_equivalent_domains,
account_revision_date = _account_revision_date,
key = _key,
public_key = _public_key,
private_key = _private_key,
premium = _premium,
premium_expiration_date = _premium_expiration_date,
renewal_reminder_date = _renewal_reminder_date,
storage = _storage,
max_storage_gb = _max_storage_gb,
gateway = _gateway,
gateway_customer_id = _gateway_customer_id,
gateway_subscription_id = _gateway_subscription_id,
license_key = _license_key,
kdf = _kdf,
kdf_iterations = _kdf_iterations,
creation_date = _creation_date,
revision_date = _revision_date
WHERE
id = _id
;
end;
$$

View File

@ -1,27 +0,0 @@
DROP FUNCTION IF EXISTS user_update_keys (UUID,VARCHAR,TEXT,TEXT,TIMESTAMPTZ);
CREATE OR REPLACE FUNCTION user_update_keys
(
_id UUID,
_security_stamp VARCHAR,
_key TEXT,
_private_key TEXT,
_revision_date TIMESTAMPTZ
)
RETURNS VOID
LANGUAGE 'plpgsql'
AS
$BODY$
BEGIN
UPDATE
"user"
SET
security_stamp = _security_stamp,
key = _key,
private_key = _private_key,
revision_date = _revision_date,
account_revision_date = _revision_date
WHERE
id = _id;
END
$BODY$

View File

@ -1,20 +0,0 @@
DROP FUNCTION IF EXISTS user_update_renewal_reminder_date (UUID,TIMESTAMPTZ);
CREATE OR REPLACE FUNCTION user_update_renewal_reminder_date
(
_id UUID,
_renewal_reminder_date TIMESTAMPTZ
)
RETURNS VOID
LANGUAGE 'plpgsql'
AS
$BODY$
BEGIN
UPDATE
"user"
SET
renewal_reminder_date = _renewal_reminder_date
WHERE
id = _id;
end
$BODY$

View File

@ -1,2 +0,0 @@
-- Example command to create the standard bitwarden user role in an existing postgreSQL instance
-- CREATE ROLE bitwarden NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT LOGIN PASSWORD 'bitwarden';

View File

@ -1,3 +0,0 @@
DROP SCHEMA if exists bitwarden cascade;
CREATE SCHEMA bitwarden AUTHORIZATION bitwarden;
ALTER ROLE bitwarden SET search_path TO bitwarden;

View File

@ -1,29 +0,0 @@
DROP TABLE IF EXISTS cipher;
CREATE TABLE IF NOT EXISTS cipher (
id UUID NOT NULL,
user_id UUID NULL,
organization_id UUID NULL,
type SMALLINT NOT NULL,
data TEXT NOT NULL,
favorites TEXT NULL,
folders TEXT NULL,
attachments TEXT NULL,
creation_date TIMESTAMPTZ NOT NULL,
revision_date TIMESTAMPTZ NOT NULL,
CONSTRAINT pk_cipher PRIMARY KEY (id),
CONSTRAINT fk_cipher_organization FOREIGN KEY (organization_id) REFERENCES Organization (id),
CONSTRAINT fk_cipher_user FOREIGN KEY (user_id) REFERENCES "user" (id)
);
CREATE INDEX ix_cipher_user_id_organization_id_include_all
ON cipher(user_id ASC, organization_id ASC)
INCLUDE (type, data, favorites, folders, attachments, creation_date, revision_date);
CREATE INDEX ix_cipher_organization_id
ON cipher(organization_id ASC);

View File

@ -1,19 +0,0 @@
DROP TABLE IF EXISTS collection;
CREATE TABLE IF NOT EXISTS collection (
id UUID NOT NULL,
organization_id UUID NOT NULL,
name TEXT NOT NULL,
external_id VARCHAR (300) NULL,
creation_date TIMESTAMPTZ NOT NULL,
revision_date TIMESTAMPTZ NOT NULL,
CONSTRAINT pk_collection PRIMARY KEY (id),
CONSTRAINT fk_collection_organization FOREIGN KEY (organization_id) REFERENCES organization (id) ON DELETE CASCADE
);
CREATE INDEX ix_collection_organization_id_include_all
ON collection(organization_id ASC)
INCLUDE(creation_date, name, revision_date);

View File

@ -1,15 +0,0 @@
DROP TABLE IF EXISTS collection_cipher;
CREATE TABLE IF NOT EXISTS collection_cipher (
collection_id UUID NOT NULL,
cipher_id UUID NOT NULL,
CONSTRAINT pk_collection_cipher PRIMARY KEY (collection_id, cipher_id),
CONSTRAINT fk_collection_cipher_cipher FOREIGN KEY (cipher_id) REFERENCES cipher (id) ON DELETE CASCADE,
CONSTRAINT fk_collection_cipher_collection FOREIGN KEY (collection_id) REFERENCES collection (id) ON DELETE CASCADE
);
CREATE INDEX ix_collection_cipher_cipher_id
ON collection_cipher(cipher_id ASC);

View File

@ -1,11 +0,0 @@
DROP TABLE IF EXISTS collection_group;
CREATE TABLE IF NOT EXISTS collection_group (
collection_id UUID NOT NULL,
group_id UUID NOT NULL,
read_only BIT NOT NULL,
CONSTRAINT pk_collection_group PRIMARY KEY (collection_id, group_id),
CONSTRAINT fk_collection_group_collection FOREIGN KEY (collection_id) REFERENCES collection (id),
CONSTRAINT fk_collection_group_group FOREIGN KEY (group_id) REFERENCES "group" (id) ON DELETE CASCADE
);

View File

@ -1,11 +0,0 @@
DROP TABLE IF EXISTS collection_user;
CREATE TABLE IF NOT EXISTS collection_user (
collection_id UUID NOT NULL,
organization_user_id UUID NOT NULL,
read_only BIT NOT NULL,
CONSTRAINT pk_collection_user PRIMARY KEY (collection_id, organization_user_id),
CONSTRAINT fk_collection_user_collection FOREIGN KEY (collection_id) REFERENCES collection (id) ON DELETE CASCADE,
CONSTRAINT fk_collection_user_organization_user FOREIGN KEY (organization_user_id) REFERENCES organization_user (id)
);

View File

@ -1,25 +0,0 @@
DROP TABLE IF EXISTS device;
CREATE TABLE IF NOT EXISTS device (
id UUID NOT NULL,
user_id UUID NOT NULL,
name VARCHAR (50) NOT NULL,
type SMALLINT NOT NULL,
identifier VARCHAR (50) NOT NULL,
push_token VARCHAR (255) NULL,
creation_date TIMESTAMPTZ NOT NULL,
revision_date TIMESTAMPTZ NOT NULL,
CONSTRAINT pk_device PRIMARY KEY (id),
CONSTRAINT fk_device_user FOREIGN KEY (user_id) REFERENCES "user" (id)
);
CREATE UNIQUE INDEX ux_device_user_id_identifier
ON device(user_id ASC, identifier ASC);
CREATE INDEX ix_device_identifier
ON device(identifier ASC);

View File

@ -1,22 +0,0 @@
DROP TABLE IF EXISTS event;
CREATE TABLE IF NOT EXISTS event (
id UUID NOT NULL,
type INT NOT NULL,
user_id UUID NULL,
organization_id UUID NULL,
cipher_id UUID NULL,
collection_id UUID NULL,
group_id UUID NULL,
organization_user_id UUID NULL,
acting_user_id UUID NULL,
device_type SMALLINT NULL,
ip_address VARCHAR(50) NULL,
date TIMESTAMPTZ NOT NULL,
CONSTRAINT pk_event PRIMARY KEY (id)
);
CREATE INDEX ix_event_date_organization_id_user_id
ON event(date DESC, organization_id ASC, acting_user_id ASC, cipher_id ASC);

View File

@ -1,18 +0,0 @@
DROP TABLE IF EXISTS folder;
CREATE TABLE IF NOT EXISTS folder (
id UUID NOT NULL,
user_id UUID NOT NULL,
name TEXT NULL,
creation_date TIMESTAMPTZ NOT NULL,
revision_date TIMESTAMPTZ NOT NULL,
CONSTRAINT pk_folder PRIMARY KEY (id),
CONSTRAINT fk_folder_user FOREIGN KEY (user_id) REFERENCES "user" (id)
);
CREATE INDEX ix_folder_user_id_include_all
ON folder(user_id ASC)
INCLUDE (name, creation_date, revision_date);

View File

@ -1,22 +0,0 @@
DROP TABLE IF EXISTS "grant";
CREATE TABLE IF NOT EXISTS "grant" (
key VARCHAR (200) NOT NULL,
type VARCHAR (50) NULL,
subject_id VARCHAR (50) NULL,
client_id VARCHAR (50) NOT NULL,
creation_date TIMESTAMPTZ NOT NULL,
expiration_date TIMESTAMPTZ NULL,
data TEXT NOT NULL,
CONSTRAINT pk_grant PRIMARY KEY (key)
);
CREATE INDEX ix_grant_subject_id_client_id_type
ON "grant"(subject_id ASC, client_id ASC, type ASC);
CREATE INDEX ix_grant_expiration_date
ON "grant"(expiration_date ASC);

View File

@ -1,14 +0,0 @@
DROP TABLE IF EXISTS "group";
CREATE TABLE IF NOT EXISTS "group" (
id UUID NOT NULL,
organization_id UUID NOT NULL,
name VARCHAR (100) NOT NULL,
access_all BIT NOT NULL,
external_id VARCHAR (300) NULL,
creation_date TIMESTAMPTZ NOT NULL,
revision_date TIMESTAMPTZ NOT NULL,
CONSTRAINT pk_group PRIMARY KEY (id),
CONSTRAINT fk_group_organization FOREIGN KEY (organization_id) REFERENCES organization (id) ON DELETE CASCADE
);

View File

@ -1,17 +0,0 @@
DROP TABLE IF EXISTS group_user;
CREATE TABLE IF NOT EXISTS group_user (
group_id UUID NOT NULL,
organization_user_id UUID NOT NULL,
CONSTRAINT Pk_group_user PRIMARY KEY (group_id, organization_user_id),
CONSTRAINT Fk_group_user_group FOREIGN KEY (group_id) REFERENCES "group" (id) ON DELETE CASCADE,
CONSTRAINT Fk_group_user_organization_user FOREIGN KEY (organization_user_id) REFERENCES organization_user (id)
);
CREATE INDEX ix_group_user_organization_user_id
ON group_user(organization_user_id ASC);

View File

@ -1,12 +0,0 @@
DROP TABLE IF EXISTS installation;
CREATE TABLE IF NOT EXISTS installation (
id UUID NOT NULL,
email VARCHAR (256) NOT NULL,
key VARCHAR (150) NOT NULL,
enabled BIT NOT NULL,
creation_date TIMESTAMPTZ NOT NULL,
CONSTRAINT pk_installation PRIMARY KEY (id)
);

View File

@ -1,44 +0,0 @@
DROP TABLE IF EXISTS organization;
CREATE TABLE IF NOT EXISTS organization (
id UUID NOT NULL,
name VARCHAR (50) NOT NULL,
business_name VARCHAR (50) NULL,
business_address_1 VARCHAR (50) NULL,
business_address_2 VARCHAR (50) NULL,
business_address_3 VARCHAR (50) NULL,
business_country VARCHAR (2) NULL,
business_tax_number VARCHAR (30) NULL,
billing_email VARCHAR (256) NOT NULL,
plan VARCHAR (50) NOT NULL,
plan_type SMALLINT NOT NULL,
seats SMALLINT NULL,
max_collections SMALLINT NULL,
use_groups BIT NOT NULL,
use_directory BIT NOT NULL,
use_events BIT NOT NULL,
use_totp BIT NOT NULL,
use_2fa BIT NOT NULL,
use_api BIT NOT NULL,
self_host BIT NOT NULL,
users_get_premium BIT NOT NULL,
storage BIGINT NULL,
max_storage_gb SMALLINT NULL,
gateway SMALLINT NULL,
gateway_customer_id VARCHAR (50) NULL,
gateway_subscription_id VARCHAR (50) NULL,
enabled BIT NOT NULL,
license_key VARCHAR (100) NULL,
api_key VARCHAR (30) NOT NULL,
two_factor_providers TEXT NULL,
expiration_date TIMESTAMPTZ NULL,
creation_date TIMESTAMPTZ NOT NULL,
revision_date TIMESTAMPTZ NOT NULL,
CONSTRAINT pk_organization PRIMARY KEY (id)
);
CREATE INDEX ix_organization_enabled
ON organization(id ASC, enabled ASC)
INCLUDE (use_totp);

View File

@ -1,28 +0,0 @@
DROP TABLE IF EXISTS organization_user;
CREATE TABLE IF NOT EXISTS organization_user (
id UUID NOT NULL,
organization_id UUID NOT NULL,
user_id UUID NULL,
email VARCHAR (256) NULL,
key TEXT NULL,
status SMALLINT NOT NULL,
type SMALLINT NOT NULL,
access_all BIT NOT NULL,
external_id VARCHAR (300) NULL,
creation_date TIMESTAMPTZ NOT NULL,
revision_date TIMESTAMPTZ NOT NULL,
CONSTRAINT pk_organization_user PRIMARY KEY (id),
CONSTRAINT fk_organization_user_organization FOREIGN KEY (organization_id) REFERENCES organization (id) ON DELETE CASCADE,
CONSTRAINT fk_organization_user_user FOREIGN KEY (user_id) REFERENCES "user" (id)
);
CREATE INDEX ix_organization_user_user_id_organization_id_status
ON organization_user(user_id ASC, organization_id ASC, Status ASC)
INCLUDE (access_all);
CREATE INDEX ix_organization_user_organization_id
ON organization_user(organization_id aSC);

View File

@ -1,29 +0,0 @@
DROP TABLE IF EXISTS "transaction";
CREATE TABLE IF NOT EXISTS "transaction" (
id UUID NOT NULL,
user_id UUID NULL,
organization_id UUID NULL,
type SMALLINT NOT NULL,
amount NUMERIC (19,4) NOT NULL,
refunded BIT NULL,
refunded_amount NUMERIC (19,4) NULL,
details VARCHAR(100) NULL,
payment_method_type SMALLINT NULL,
gateway SMALLINT NULL,
gateway_id VARCHAR(50) NULL,
creation_date TIMESTAMPTZ NOT NULL,
CONSTRAINT pk_transaction PRIMARY KEY (id),
CONSTRAINT fk_transaction_user FOREIGN KEY (user_id) REFERENCES "user" (id) ON DELETE CASCADE,
CONSTRAINT fk_transaction_organization FOREIGN KEY (organization_id) REFERENCES organization (id) ON DELETE CASCADE
);
CREATE UNIQUE INDEX ix_transaction_gateway_gatewayid
ON "transaction"(gateway ASC, gateway_id ASC)
WHERE gateway IS NOT NULL AND gateway_id IS NOT NULL;
CREATE INDEX ix_transaction_user_id_organization_id_creation_date
ON "transaction"(user_id ASC, Organization_id ASC, Creation_date ASC);

View File

@ -1,22 +0,0 @@
DROP TABLE IF EXISTS u2f CASCADE;
CREATE TABLE IF NOT EXISTS u2f (
id SERIAL NOT NULL,
user_id UUID NOT NULL,
key_handle VARCHAR (200) NULL,
challenge VARCHAR (200) NOT NULL,
app_id VARCHAR (50) NOT NULL,
version VARCHAR (20) NOT NULL,
creation_date TIMESTAMPTZ NOT NULL,
CONSTRAINT pk_u2f PRIMARY KEY (id),
CONSTRAINT fk_u2f_user FOREIGN KEY (user_id) REFERENCES "user" (id)
);
CREATE INDEX ix_u2f_creation_date
ON u2f(creation_date ASC);
CREATE INDEX ix_u2f_user_id
ON u2f(user_id ASC);

View File

@ -1,43 +0,0 @@
DROP TABLE IF EXISTS "user" CASCADE;
CREATE TABLE "user" (
id UUID NOT NULL,
name VARCHAR (50) NULL,
email VARCHAR (256) NOT NULL,
email_verified BOOLEAN NOT NULL,
master_password VARCHAR (300) NOT NULL,
master_password_hint VARCHAR (50) NULL,
culture VARCHAR (10) NOT NULL,
security_stamp VARCHAR (50) NOT NULL,
two_factor_providers TEXT NULL,
two_factor_recovery_code VARCHAR (32) NULL,
equivalent_domains TEXT NULL,
excluded_global_equivalent_domains TEXT NULL,
account_revision_date TIMESTAMPTZ NOT NULL,
key TEXT NULL,
public_key TEXT NULL,
private_key TEXT NULL,
premium BOOLEAN NOT NULL,
premium_expiration_date TIMESTAMPTZ NULL,
renewal_reminder_date TIMESTAMPTZ NULL,
storage BIGINT NULL,
max_storage_gb SMALLINT NULL,
gateway SMALLINT NULL,
gateway_customer_id VARCHAR (50) NULL,
gateway_subscription_id VARCHAR (50) NULL,
license_key VARCHAR (100) NULL,
kdf SMALLINT NOT NULL,
kdf_iterations INT NOT NULL,
creation_date TIMESTAMPTZ NOT NULL,
revision_date TIMESTAMPTZ NOT NULL,
CONSTRAINT pk_user PRIMARY KEY (id)
);
CREATE UNIQUE INDEX ix_user_email
ON "user"(email ASC);
CREATE INDEX ix_user_premium_premium_expiration_date_renewal_reminder_date
ON "user"(premium ASC, premium_expiration_date ASC, renewal_reminder_date ASC);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,25 +0,0 @@
CREATE OR REPLACE 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

@ -1,18 +0,0 @@
CREATE OR REPLACE 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

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

View File

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

View File

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

View File

@ -1,6 +0,0 @@
CREATE VIEW u2f_view
AS
SELECT
*
FROM
u2f;

View File

@ -1,6 +0,0 @@
CREATE VIEW user_view
AS
SELECT
*
FROM
"user";