🏡 index : ~doyle/chartered.git

author Jordan Doyle <jordan@doyle.la> 2022-09-09 22:14:38.0 +01:00:00
committer Jordan Doyle <jordan@doyle.la> 2022-09-09 22:14:38.0 +01:00:00
commit
ec84c1dbc32507246104db20f0cf6c34767dae2f [patch]
tree
96e555720e0e77f0c847738ca5e8390c8b84ee3a
parent
3101fd7ef95ff5c58dc40cf3e9b7e566dcf93577
download
ec84c1dbc32507246104db20f0cf6c34767dae2f.tar.gz

Fix UUID types in Postgres migrations



Diff

 migrations/postgres/2021-08-31-214501_create_crates_table/up.sql      | 6 ++++--
 migrations/postgres/2021-11-08-005634_update_sessions_add_uuid/up.sql | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/migrations/postgres/2021-08-31-214501_create_crates_table/up.sql b/migrations/postgres/2021-08-31-214501_create_crates_table/up.sql
index 43430c2..6953313 100644
--- a/migrations/postgres/2021-08-31-214501_create_crates_table/up.sql
+++ a/migrations/postgres/2021-08-31-214501_create_crates_table/up.sql
@@ -1,6 +1,6 @@
CREATE TABLE users (
    id INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
    uuid UUID NOT NULL UNIQUE,
    uuid BYTEA NOT NULL UNIQUE,
    username VARCHAR(255) NOT NULL UNIQUE,
    password CHAR(60),
    name VARCHAR(255),
@@ -12,7 +12,7 @@

CREATE TABLE organisations (
    id INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
    uuid UUID NOT NULL UNIQUE,
    uuid BYTEA NOT NULL UNIQUE,
    name VARCHAR(255) NOT NULL UNIQUE,
    description TEXT NOT NULL DEFAULT '',
    public BOOLEAN NOT NULL DEFAULT FALSE
@@ -73,7 +73,7 @@

CREATE TABLE user_ssh_keys (
    id INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
    uuid UUID NOT NULL UNIQUE,
    uuid BYTEA NOT NULL UNIQUE,
    name VARCHAR(255) NOT NULL,
    user_id INTEGER NOT NULL,
    ssh_key BYTEA NOT NULL UNIQUE,
diff --git a/migrations/postgres/2021-11-08-005634_update_sessions_add_uuid/up.sql b/migrations/postgres/2021-11-08-005634_update_sessions_add_uuid/up.sql
index 7a7721a..20e81db 100644
--- a/migrations/postgres/2021-11-08-005634_update_sessions_add_uuid/up.sql
+++ a/migrations/postgres/2021-11-08-005634_update_sessions_add_uuid/up.sql
@@ -1,5 +1,5 @@
-- drop all sessions before creating NOT NULL column
DELETE FROM user_sessions;

ALTER TABLE user_sessions ADD COLUMN uuid UUID NOT NULL;
ALTER TABLE user_sessions ADD COLUMN uuid BYTEA NOT NULL;
CREATE UNIQUE INDEX unique_user_sessions_uuid ON user_sessions(uuid);