summaryrefslogtreecommitdiff
path: root/model/sql/migration000.sql
blob: 061eefddd7ea8b9b18da7aa2beb77443c5181642 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
-- Database schema version 0 corresponds to what ceres v0.4.0 used.

PRAGMA foreign_keys = ON;

CREATE TABLE metadata (
	key   TEXT PRIMARY KEY,
	value TEXT
);

CREATE TABLE recipes (
	id           INTEGER PRIMARY KEY,
	title        TEXT    NOT NULL,
	portions     INTEGER NOT NULL,
	url          TEXT    NOT NULL,
	notes        TEXT    NOT NULL,
	created      INTEGER NOT NULL,     -- Unix time stamp
	last_changed INTEGER NOT NULL      -- Unix time stamp
);

CREATE TABLE steps (
	id      INTEGER PRIMARY KEY,
	'index' INTEGER NOT NULL,
	text    TEXT    NOT NULL,
	recipe  INTEGER NOT NULL,
	FOREIGN KEY(recipe) REFERENCES recipes(id)
);

CREATE TABLE ingredients (
	id      INTEGER PRIMARY KEY,
	'index' INTEGER NOT NULL,
	amount  REAL    NOT NULL,
	unit    TEXT    NOT NULL,
	'type'  TEXT    NOT NULL,
	step    INTEGER NOT NULL,
	FOREIGN KEY(step) REFERENCES steps(id)
);

INSERT INTO metadata
	(key, value)
VALUES
	('version', 'v0.4.0');