From 8f6a954ccac9d8d3133c377d7e882485c8a1cf14 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Sun, 13 Aug 2023 23:54:42 +0100 Subject: [PATCH] Fix datatypes and drop unused duplicate index. --- .../java/me/kavin/piped/utils/obj/db/User.java | 5 +++-- src/main/resources/changelog/version/0-1-init.sql | 14 ++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/kavin/piped/utils/obj/db/User.java b/src/main/java/me/kavin/piped/utils/obj/db/User.java index fe3ceb4..2b8f603 100644 --- a/src/main/java/me/kavin/piped/utils/obj/db/User.java +++ b/src/main/java/me/kavin/piped/utils/obj/db/User.java @@ -8,9 +8,10 @@ import java.util.Set; import java.util.UUID; @Entity -@Table(name = "users", indexes = {@Index(columnList = "id", name = "users_id_idx"), +@Table(name = "users", indexes = { @Index(columnList = "username", name = "username_idx"), - @Index(columnList = "session_id", name = "users_session_id_idx")}) + @Index(columnList = "session_id", name = "users_session_id_idx") +}) public class User implements Serializable { private static final long serialVersionUID = 1L; diff --git a/src/main/resources/changelog/version/0-1-init.sql b/src/main/resources/changelog/version/0-1-init.sql index d01cfee..e44fd80 100644 --- a/src/main/resources/changelog/version/0-1-init.sql +++ b/src/main/resources/changelog/version/0-1-init.sql @@ -1,11 +1,13 @@ CREATE TABLE IF NOT EXISTS users ( id SERIAL NOT NULL, - password STRING NULL, - session_id STRING(36) NULL, - username STRING(24) NULL UNIQUE, - CONSTRAINT users_pkey PRIMARY KEY (id ASC), - INDEX users_id_idx (id ASC), - INDEX username_idx (username ASC) + password TEXT NULL, + session_id VARCHAR(36) NULL, + username VARCHAR(24) NULL UNIQUE, + CONSTRAINT users_pkey PRIMARY KEY (id) ); +DROP INDEX IF EXISTS users_id_idx; + +CREATE INDEX IF NOT EXISTS username_idx ON users (username ASC); + --rollback DROP TABLE IF EXISTS users;