From fd3f4bb766a7dd00d4595a6eb9d8fde59b54fd85 Mon Sep 17 00:00:00 2001 From: Caio Fernando Date: Wed, 2 Oct 2024 21:24:53 -0300 Subject: [PATCH] update users sql --- .../database/migrations/20240922224814_users.sql | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/internal/database/migrations/20240922224814_users.sql b/internal/database/migrations/20240922224814_users.sql index 2846abe..1fa07d6 100644 --- a/internal/database/migrations/20240922224814_users.sql +++ b/internal/database/migrations/20240922224814_users.sql @@ -1,13 +1,21 @@ -- +goose Up -- +goose StatementBegin -CREATE TABLE IF NOT EXISTS users ( +CREATE TABLE users ( id SERIAL PRIMARY KEY, + serial VARCHAR(26) NOT NULL UNIQUE, name VARCHAR(255) NOT NULL, - email VARCHAR(255) NOT NULL UNIQUE, + surname VARCHAR(255) NOT NULL, + email VARCHAR(320) NOT NULL UNIQUE, password VARCHAR(255) NOT NULL, + terms_and_privacy_at TIMESTAMPTZ, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), - updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() + updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW() CONSTRAINT email_format CHECK ( + email ~ '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}$' + ) ); + +CREATE INDEX idx_users_email ON users (email); +CREATE INDEX idx_users_serial ON users (serial); -- +goose StatementEnd -- +goose Down