learn-go/snippetbox/db/initdb.d/init.sql
tamsin johnson 569f2fc0a9 lets-go:4-x
2024-01-25 12:41:08 -08:00

15 lines
370 B
SQL

USE snippetbox;
CREATE TABLE snippets (
id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(100) NOT NULL,
content TEXT NOT NULL,
created DATETIME NOT NULL,
expires DATETIME NOT NULL
);
CREATE USER 'web';
GRANT SELECT, INSERT, UPDATE, DELETE ON snippetbox.* TO 'web' IDENTIFIED BY 'dbpass';
CREATE INDEX idx_snippets_created ON snippets(created);