Have got first run working and publishing to Netlify

This commit is contained in:
Leon Mika 2026-02-26 22:23:47 +11:00
parent b7e0269e9d
commit 30d99eeb9e
22 changed files with 472 additions and 47 deletions

View file

@ -1,5 +1,5 @@
-- name: SelectSitesOwnedByUser :many
SELECT * FROM sites WHERE owner_id = ?;
SELECT * FROM sites WHERE owner_id = ? ORDER BY title ASC;
-- name: SelectSiteByID :one
SELECT * FROM sites WHERE id = ?;
@ -8,6 +8,10 @@ SELECT * FROM sites WHERE id = ?;
INSERT INTO sites (
owner_id,
title,
tagline
) VALUES (?, ?, ?)
RETURNING id;
tagline,
created_at
) VALUES (?, ?, ?, ?)
RETURNING id;
-- name: HasUsersAndSites :one
SELECT (SELECT COUNT(*) FROM users) > 0 AND (SELECT COUNT(*) FROM sites) > 0 AS has_users_and_sites;

View file

@ -5,7 +5,7 @@ SELECT * FROM users WHERE username = ? LIMIT 1;
SELECT * FROM users WHERE id = ? LIMIT 1;
-- name: InsertUser :one
INSERT INTO users (username, password) VALUES (?, ?) RETURNING id;
INSERT INTO users (username, password, created_at) VALUES (?, ?, ?) RETURNING id;
-- name: UpdateUser :exec
UPDATE users SET username = ?, password = ? WHERE id = ?;

View file

@ -1,15 +1,17 @@
CREATE TABLE users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT NOT NULL,
password TEXT NOT NULL
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT NOT NULL,
password TEXT NOT NULL,
created_at INTEGER NOT NULL
);
CREATE UNIQUE INDEX idx_users_username ON users (username);
CREATE TABLE sites (
id INTEGER PRIMARY KEY AUTOINCREMENT,
owner_id INTEGER NOT NULL,
title TEXT NOT NULL,
tagline TEXT NOT NULL,
id INTEGER PRIMARY KEY AUTOINCREMENT,
owner_id INTEGER NOT NULL,
title TEXT NOT NULL,
tagline TEXT NOT NULL,
created_at INTEGER NOT NULL,
FOREIGN KEY (owner_id) REFERENCES users (id) ON DELETE CASCADE
);