creating chirps!

This commit is contained in:
2025-03-11 19:08:34 +02:00
parent 5618aeb439
commit de5f090a9c
5 changed files with 105 additions and 22 deletions

View File

@@ -0,0 +1,4 @@
-- name: CreateChirp :one
INSERT INTO chirps (id, created_at, updated_at, body, user_id)
VALUES (gen_random_uuid(), NOW(), NOW(), $1, $2)
RETURNING *;

11
sql/schema/002_chirps.sql Normal file
View File

@@ -0,0 +1,11 @@
-- +goose Up
CREATE TABLE chirps(
id UUID PRIMARY KEY,
created_at TIMESTAMP not null DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP not null DEFAULT CURRENT_TIMESTAMP,
body TEXT not null UNIQUE,
user_id UUID not null REFERENCES users(id) ON DELETE CASCADE
);
-- +goose Down
DROP TABLE chirps;