-- name: TableCreate :exec
CREATE TABLE IF NOT EXISTS gb (
  id INTEGER NOT NULL PRIMARY KEY,
  msg TEXT NOT NULL,
  stamp DATETIME NOT NULL,
  flags INTEGER NOT NULL DEFAULT 0
);

-- name: GetPost :one
SELECT * FROM gb
WHERE id = ? LIMIT 1;

-- name: GetPosts :many
SELECT * FROM gb
ORDER BY stamp DESC;

-- name: AddPost :one
INSERT INTO gb (
  msg, stamp, flags
) VALUES (
  ?, ?, ?
)
RETURNING *;

-- name: UpdateMsg :exec
UPDATE gb
set msg = ?
WHERE id = ?;

-- name: UpdateFlags :exec
UPDATE gb
set flags = ?
WHERE id = ?;

-- name: DeleteFilm :exec
DELETE FROM gb
WHERE id = ?;
