1
0
mirror of https://github.com/bitwarden/server synced 2026-01-09 03:53:42 +00: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

@@ -0,0 +1,43 @@
DROP TABLE IF EXISTS "user" CASCADE;
CREATE TABLE "user" (
id UUID NOT NULL,
name VARCHAR (50) NULL,
email VARCHAR (50) NOT NULL,
email_verified BIT 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 BIT 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);