This repository has been archived on 2026-01-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
cover-letter-templater/backend/db/migrations.sql
2025-07-12 15:05:58 +03:00

34 lines
886 B
SQL

CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
email TEXT NOT NULL UNIQUE,
"name" TEXT NOT NULL,
"password" TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS "templates" (
"id" SERIAL PRIMARY KEY,
"user_id" INTEGER NOT NULL,
"name" VARCHAR(50) NOT NULL UNIQUE,
"template" TEXT NOT NULL,
"created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT fk_user
FOREIGN KEY (user_id)
REFERENCES users (id)
ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS "cover_letters" (
"id" SERIAL PRIMARY KEY,
"user_id" INTEGER NOT NULL,
"name" VARCHAR(50) NOT NULL UNIQUE,
"letter" TEXT NOT NULL,
"created_at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT fk_user
FOREIGN KEY (user_id)
REFERENCES users (id)
ON DELETE CASCADE
);