0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-09 08:20:45 -05:00

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;

View file

@ -15,30 +15,41 @@
(def +migrations+
{:name "uxbox-main"
:steps
[{:desc "Initial triggers and utils."
:name "0001-main"
:fn (mg/resource "migrations/0001.main.sql")}
{:desc "Initial auth related tables"
:name "0002-users"
:fn (mg/resource "migrations/0002.users.sql")}
{:desc "Initial projects tables"
:name "0003-projects"
:fn (mg/resource "migrations/0003.projects.sql")}
{:desc "Initial tasks related tables"
:name "0004-tasks"
:fn (mg/resource "migrations/0004.tasks.sql")}
{:desc "Initial libraries tables"
:name "0005-libraries"
:fn (mg/resource "migrations/0005.libraries.sql")}
{:desc "Initial presence tables"
:name "0006-presence"
:fn (mg/resource "migrations/0006.presence.sql")}
{:desc "Remove version"
:name "0007-remove-version"
:fn (mg/resource "migrations/0007.remove-version.sql")}]})
{:desc "Initial generic token tables"
:name "0008-generic-token"
:fn (mg/resource "migrations/0007.generic-token.sql")}]})
[{:desc "Add initial extensions and functions."
:name "0001-add-extensions"
:fn (mg/resource "migrations/0001-add-extensions.sql")}
{:desc "Add profile related tables"
:name "0002-add-profile-tables"
:fn (mg/resource "migrations/0002-add-profile-tables.sql")}
{:desc "Add project related tables"
:name "0003-add-project-tables"
:fn (mg/resource "migrations/0003-add-project-tables.sql")}
{:desc "Add tasks related tables"
:name "0004-add-tasks-tables"
:fn (mg/resource "migrations/0004-add-tasks-tables.sql")}
{:desc "Add libraries related tables"
:name "0005-add-libraries-tables"
:fn (mg/resource "migrations/0005-add-libraries-tables.sql")}
{:desc "Add presence related tables"
:name "0006-add-presence-tables"
:fn (mg/resource "migrations/0006-add-presence-tables.sql")}
{:desc "Drop version field from page table."
:name "0007-drop-version-field-from-page-table"
:fn (mg/resource "migrations/0007-drop-version-field-from-page-table.sql")}
{:desc "Add generic token related tables."
:name "0008-add-generic-token-table.sql"
:fn (mg/resource "migrations/0008-add-generic-token-table.sql")}
{:desc "Drop the profile_email table"
:name "0009-drop-profile-email-table.sql"
:fn (mg/resource "migrations/0009-drop-profile-email-table.sql")}]})
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Entry point