From 773d8dffd18119bc369eda8b23e13008b1589fd3 Mon Sep 17 00:00:00 2001 From: Ethan Girouard Date: Fri, 26 Jun 2026 18:05:56 -0400 Subject: [PATCH] Create users table --- .../2026-06-25-233206-0000_create_users_table/down.sql | 2 ++ .../2026-06-25-233206-0000_create_users_table/up.sql | 8 ++++++++ src/schema.rs | 9 +++++++++ 3 files changed, 19 insertions(+) create mode 100644 migrations/2026-06-25-233206-0000_create_users_table/down.sql create mode 100644 migrations/2026-06-25-233206-0000_create_users_table/up.sql diff --git a/migrations/2026-06-25-233206-0000_create_users_table/down.sql b/migrations/2026-06-25-233206-0000_create_users_table/down.sql new file mode 100644 index 0000000..ab7273f --- /dev/null +++ b/migrations/2026-06-25-233206-0000_create_users_table/down.sql @@ -0,0 +1,2 @@ +DROP INDEX users_username_idx; +DROP TABLE users; diff --git a/migrations/2026-06-25-233206-0000_create_users_table/up.sql b/migrations/2026-06-25-233206-0000_create_users_table/up.sql new file mode 100644 index 0000000..1008425 --- /dev/null +++ b/migrations/2026-06-25-233206-0000_create_users_table/up.sql @@ -0,0 +1,8 @@ +CREATE TABLE users ( + id INTEGER PRIMARY KEY UNIQUE NOT NULL GENERATED ALWAYS AS IDENTITY, + username VARCHAR UNIQUE NOT NULL, + hashed_password VARCHAR NOT NULL, + created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() +); + +CREATE UNIQUE INDEX users_username_idx ON users(username); diff --git a/src/schema.rs b/src/schema.rs index d9a52af..db95303 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -1 +1,10 @@ // @generated automatically by Diesel CLI. + +diesel::table! { + users (id) { + id -> Int4, + username -> Varchar, + hashed_password -> Varchar, + created_at -> Timestamptz, + } +}