diff options
Diffstat (limited to 'model/migrations')
-rw-r--r-- | model/migrations/migration001.go | 15 | ||||
-rw-r--r-- | model/migrations/migration001.sql | 29 |
2 files changed, 44 insertions, 0 deletions
diff --git a/model/migrations/migration001.go b/model/migrations/migration001.go new file mode 100644 index 0000000..11f062f --- /dev/null +++ b/model/migrations/migration001.go @@ -0,0 +1,15 @@ +package migrations + +import ( + "database/sql" + _ "embed" +) + +//go:embed migration001.sql +var migration001sql string + +func Migration001(tx *sql.Tx) error { + _, err := tx.Exec(migration001sql) + + return err +} diff --git a/model/migrations/migration001.sql b/model/migrations/migration001.sql new file mode 100644 index 0000000..46f9fc6 --- /dev/null +++ b/model/migrations/migration001.sql @@ -0,0 +1,29 @@ +PRAGMA foreign_keys = ON; + +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) +); |