diff options
author | xengineering <me@xengineering.eu> | 2024-10-15 21:23:10 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2024-10-21 21:34:26 +0200 |
commit | 118e1c69057e4e7b6ab3e730d5628b4822ed4c4d (patch) | |
tree | 0d4d49c29475715b932e780b976b1379c7aa23d3 /model/migrations | |
parent | 1904f50084660ce587a67d49939fd0734fd8a582 (diff) | |
download | ceres-118e1c69057e4e7b6ab3e730d5628b4822ed4c4d.tar ceres-118e1c69057e4e7b6ab3e730d5628b4822ed4c4d.tar.zst ceres-118e1c69057e4e7b6ab3e730d5628b4822ed4c4d.zip |
model: Save int-based schema version in DB
Ceres v0.4.0 used the `git describe` output as database schema and
enforced exactly matching versions between the database and the
executable.
This turned out to be not flexible enough. It is way easier to version
the database separately with a simple integer and require the same
database schema version integer between the application and the
database.
This commit implements this new approach.
Diffstat (limited to 'model/migrations')
-rw-r--r-- | model/migrations/migration001.go | 15 | ||||
-rw-r--r-- | model/migrations/migration001.sql | 29 |
2 files changed, 0 insertions, 44 deletions
diff --git a/model/migrations/migration001.go b/model/migrations/migration001.go deleted file mode 100644 index 11f062f..0000000 --- a/model/migrations/migration001.go +++ /dev/null @@ -1,15 +0,0 @@ -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 deleted file mode 100644 index 46f9fc6..0000000 --- a/model/migrations/migration001.sql +++ /dev/null @@ -1,29 +0,0 @@ -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) -); |