Initial open source release
This commit is contained in:
commit
74992e893f
377 changed files with 118084 additions and 0 deletions
64
deploy/migrations/0003_startup_config_security.up.sql
Normal file
64
deploy/migrations/0003_startup_config_security.up.sql
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
-- 0003_startup_config_security: data-backed startup config, countries and account security.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS account_passwords (
|
||||
user_id BIGINT PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE,
|
||||
has_recovery BOOLEAN NOT NULL DEFAULT false,
|
||||
has_secure_values BOOLEAN NOT NULL DEFAULT false,
|
||||
has_password BOOLEAN NOT NULL DEFAULT false,
|
||||
hint VARCHAR(256) NOT NULL DEFAULT '',
|
||||
email_unconfirmed_pattern VARCHAR(256) NOT NULL DEFAULT '',
|
||||
login_email_pattern VARCHAR(256) NOT NULL DEFAULT '',
|
||||
secure_random BYTEA NOT NULL DEFAULT decode('74656c657372762d746465736b746f702d6465762d7365637572652d72616e64', 'hex'),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS app_configs (
|
||||
client VARCHAR(64) PRIMARY KEY,
|
||||
hash INT NOT NULL,
|
||||
config_json JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS countries (
|
||||
iso2 VARCHAR(2) PRIMARY KEY,
|
||||
default_name VARCHAR(128) NOT NULL,
|
||||
name VARCHAR(128) NOT NULL DEFAULT '',
|
||||
hidden BOOLEAN NOT NULL DEFAULT false,
|
||||
order_index INT NOT NULL DEFAULT 0,
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS country_codes (
|
||||
id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
iso2 VARCHAR(2) NOT NULL REFERENCES countries(iso2) ON DELETE CASCADE,
|
||||
country_code VARCHAR(16) NOT NULL,
|
||||
prefixes TEXT[] NOT NULL DEFAULT '{}',
|
||||
patterns TEXT[] NOT NULL DEFAULT '{}',
|
||||
order_index INT NOT NULL DEFAULT 0,
|
||||
UNIQUE (iso2, country_code)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS temp_auth_key_bindings (
|
||||
temp_auth_key_id BIGINT PRIMARY KEY REFERENCES auth_keys(auth_key_id) ON DELETE CASCADE,
|
||||
perm_auth_key_id BIGINT NOT NULL,
|
||||
nonce BIGINT NOT NULL,
|
||||
expires_at INT NOT NULL,
|
||||
encrypted_message BYTEA NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
|
||||
INSERT INTO app_configs (client, hash, config_json)
|
||||
VALUES ('tdesktop', 1, '{}'::jsonb)
|
||||
ON CONFLICT (client) DO NOTHING;
|
||||
|
||||
INSERT INTO countries (iso2, default_name, name, hidden, order_index)
|
||||
VALUES
|
||||
('US', 'United States', '', false, 10),
|
||||
('CN', 'China', '', false, 20)
|
||||
ON CONFLICT (iso2) DO NOTHING;
|
||||
|
||||
INSERT INTO country_codes (iso2, country_code, prefixes, patterns, order_index)
|
||||
VALUES
|
||||
('US', '1', ARRAY['1'], '{}'::text[], 10),
|
||||
('CN', '86', ARRAY['86'], '{}'::text[], 20)
|
||||
ON CONFLICT (iso2, country_code) DO NOTHING;
|
||||
Loading…
Add table
Add a link
Reference in a new issue