CREATE VIRTUAL TABLE article_search USING fts5(author, title, content, slug);

CREATE TABLE article (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  slug VARCHAR(256) NOT NULL,
  title VARCHAR(256) NOT NULL,
  author VARCHAR(256) NOT NULL,
  content text,
  published_date DATETIME NOT NULL,
  UNIQUE(slug)
);

CREATE TABLE category (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  name VARCHAR(128) NOT NULL,
  UNIQUE(name)
);

CREATE TABLE tag (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  name VARCHAR(128) NOT NULL,
  UNIQUE(name)
);

CREATE TABLE article__category (
  article_id INTEGER,
  category_id INTEGER,
  UNIQUE(category_id, article_id)
);

CREATE TABLE article__tag (
  article_id INTEGER,
  tag_id INTEGER,
  UNIQUE(tag_id, article_id)
);
