From 3747204267e8b75bc77d6c0962b67bbe018dad15 Mon Sep 17 00:00:00 2001
From: Joel Klinghed <the_jk@spawned.biz>
Date: Thu, 9 Jan 2025 21:20:17 +0100
Subject: Add string id for project and reduce usage of numeric ids in general

User: username must be unique, use as primary key and drop id.
---
 server/migrations/1_initial_eyeballs.sql | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

(limited to 'server/migrations/1_initial_eyeballs.sql')

diff --git a/server/migrations/1_initial_eyeballs.sql b/server/migrations/1_initial_eyeballs.sql
index b839c42..6dcd8f1 100644
--- a/server/migrations/1_initial_eyeballs.sql
+++ b/server/migrations/1_initial_eyeballs.sql
@@ -1,5 +1,5 @@
 CREATE TABLE IF NOT EXISTS projects (
-       id BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
+       id VARCHAR(128) NOT NULL PRIMARY KEY,
        title VARCHAR(1024) NOT NULL,
        description MEDIUMTEXT NOT NULL DEFAULT '',
        remote VARCHAR(2048) NOT NULL,
@@ -7,15 +7,14 @@ CREATE TABLE IF NOT EXISTS projects (
 );
 
 CREATE TABLE IF NOT EXISTS users (
-       id BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
-       username VARCHAR(256) NOT NULL UNIQUE,
+       id VARCHAR(128) NOT NULL PRIMARY KEY,
        name VARCHAR(1024) NOT NULL DEFAULT '',
        dn VARCHAR(256) NULL
 );
 
 CREATE TABLE IF NOT EXISTS project_users (
-       project BIGINT UNSIGNED NOT NULL,
-       user BIGINT UNSIGNED NOT NULL,
+       project VARCHAR(128) NOT NULL,
+       user VARCHAR(128) NOT NULL,
        default_role TINYINT UNSIGNED NOT NULL,
        maintainer BOOLEAN NOT NULL DEFAULT 0,
        PRIMARY KEY (project, user),
@@ -33,8 +32,8 @@ CREATE TABLE IF NOT EXISTS project_users (
 
 CREATE TABLE IF NOT EXISTS reviews (
        id BIGINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
-       project BIGINT UNSIGNED NOT NULL,
-       owner BIGINT UNSIGNED NOT NULL,
+       project VARCHAR(128) NOT NULL,
+       owner VARCHAR(128) NOT NULL,
        title VARCHAR(1024) NOT NULL,
        description MEDIUMTEXT NOT NULL DEFAULT '',
        state TINYINT UNSIGNED NOT NULL DEFAULT 0,
@@ -55,7 +54,7 @@ CREATE TABLE IF NOT EXISTS reviews (
 
 CREATE TABLE IF NOT EXISTS review_users (
        review BIGINT UNSIGNED NOT NULL,
-       user BIGINT UNSIGNED NOT NULL,
+       user VARCHAR(128) NOT NULL,
        role TINYINT UNSIGNED NOT NULL DEFAULT 0,
        PRIMARY KEY (review, user),
 
-- 
cgit v1.2.3-70-g09d2

