Fix naming inconsistencies on migrations.

This commit is contained in:
Andrey Antukh
2020-05-25 13:45:52 +02:00
parent 7d5f9c1078
commit 7bda554889
11 changed files with 87 additions and 33 deletions

View File

@@ -6,10 +6,7 @@ CREATE TABLE profile (
deleted_at timestamptz NULL,
fullname text NOT NULL DEFAULT '',
email text NOT NULL,
pending_email text NULL,
photo text NOT NULL,
password text NOT NULL,
@@ -35,6 +32,27 @@ VALUES ('00000000-0000-0000-0000-000000000000'::uuid,
'!');
--- NOTE: this table is deleted in the next migrations
CREATE TABLE profile_email (
profile_id uuid NOT NULL REFERENCES profile(id) ON DELETE CASCADE,
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
verified_at timestamptz NULL DEFAULT NULL,
email text NOT NULL,
is_main boolean NOT NULL DEFAULT false,
is_verified boolean NOT NULL DEFAULT false
);
CREATE INDEX profile_email__profile_id__idx
ON profile_email (profile_id);
CREATE UNIQUE INDEX profile_email__email__idx
ON profile_email (email);
CREATE TABLE team (
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),
@@ -104,6 +122,20 @@ BEFORE UPDATE ON profile_attr
FOR EACH ROW EXECUTE PROCEDURE update_modified_at();
--- NOTE: this table is removed in the following migrations
CREATE TABLE password_recovery_token (
profile_id uuid NOT NULL REFERENCES profile(id) ON DELETE CASCADE,
token text NOT NULL,
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
used_at timestamptz NULL,
PRIMARY KEY (profile_id, token)
);
CREATE TABLE session (
id uuid PRIMARY KEY DEFAULT uuid_generate_v4(),

View File

@@ -0,0 +1,14 @@
--- Delete previously token related tables
DROP TABLE password_recovery_token;
--- Create a new generic table for store tokens.
CREATE TABLE generic_token (
token text PRIMARY KEY,
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
valid_until timestamptz NOT NULL,
content bytea NOT NULL
);
COMMENT ON TABLE generic_token IS 'Table for generic tokens storage';

View File

@@ -1,6 +0,0 @@
CREATE TABLE generic_token (
token text PRIMARY KEY,
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
valid_until timestamptz NOT NULL,
content bytea NOT NULL
);

View File

@@ -0,0 +1,3 @@
DROP INDEX profile_email__profile_id__idx;
DROP INDEX profile_email__email__idx;
DROP TABLE profile_email;