feat: init.sql file update to handle incomming feat user auth
This commit is contained in:
parent
4b558dd4c3
commit
2965a4a18e
22
init.sql
22
init.sql
@ -2,9 +2,29 @@ CREATE TABLE IF NOT EXISTS users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
email VARCHAR(255) NOT NULL UNIQUE,
|
||||
hashed_password VARCHAR(255) NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
failed_attempts INTEGER NOT NULL DEFAULT 0,
|
||||
is_locked BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
locked_at TIMESTAMP,
|
||||
last_failed_at TIMESTAMP,
|
||||
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
is_superuser BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE OR REPLACE FUNCTION update_updated_at_column()
|
||||
RETURNS TRIGGER AS $$
|
||||
BEGIN
|
||||
NEW.updated_at = NOW();
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ language 'plpgsql';
|
||||
|
||||
CREATE TRIGGER update_users_updated_at
|
||||
BEFORE UPDATE ON users
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION update_updated_at_column();
|
||||
|
||||
CREATE TABLE IF NOT EXISTS otps (
|
||||
id SERIAL PRIMARY KEY,
|
||||
email VARCHAR(255) NOT NULL UNIQUE,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user