From f06b3a6d7c07abd916038fa187584a30bfb5f1de Mon Sep 17 00:00:00 2001
From: Sebastian Baltes <Sebastian.Baltes@uni-bayreuth.de>
Date: Tue, 27 May 2025 20:10:59 +0200
Subject: Add code for assignment 5

---
 .../main/resources/db/migration/V2__create_users_table.sql  | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 data/src/main/resources/db/migration/V2__create_users_table.sql

(limited to 'data/src/main/resources/db/migration/V2__create_users_table.sql')

diff --git a/data/src/main/resources/db/migration/V2__create_users_table.sql b/data/src/main/resources/db/migration/V2__create_users_table.sql
new file mode 100644
index 0000000..b597ad8
--- /dev/null
+++ b/data/src/main/resources/db/migration/V2__create_users_table.sql
@@ -0,0 +1,13 @@
+SET TIME ZONE 'UTC';
+
+CREATE SEQUENCE user_seq START WITH 1 INCREMENT BY 1;
+
+CREATE TABLE users (
+    id bigint NOT NULL PRIMARY KEY,
+    created_at timestamp NOT NULL,
+    updated_at timestamp NOT NULL,
+    login_name varchar(255) NOT NULL UNIQUE CHECK (login_name <> ''),
+    email_address varchar(254) NOT NULL UNIQUE CHECK (length(email_address) > 2), -- https://stackoverflow.com/a/574698/1974143, https://stackoverflow.com/a/1423203/1974143
+    first_name varchar(255) NOT NULL CHECK (first_name <> ''),
+    last_name varchar(255) NOT NULL CHECK (last_name <> '')
+);
-- 
cgit v1.2.3

