You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ratchet/migrations/10_snippets.up.sql

21 lines
569 B
SQL

PRAGMA foreign_keys=1;
CREATE TABLE snippets (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT,
content TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
expires_at DATETIME NOT NULL
);
-- Add an index on the created column.
CREATE INDEX idx_snippets_created ON snippets(created_at);
-- Add a trigger to keep timestamp updated.
CREATE TRIGGER snippet_update_timestamp
AFTER UPDATE ON snippets
FOR EACH ROW
BEGIN
UPDATE snippets SET updated_at = CURRENT_TIMESTAMP WHERE id = OLD.id;
END;