diff --git a/Makefile b/Makefile index 2bb435d..481e3fc 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,8 @@ ################################################################################ ## Phony targets -.PHONY: apispecs clean diagram help steps release run +.PHONY: apispecs clean clean-db diagram help steps release run +SQLITE_DB=otto.db # Cute hack thanks to: # https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html @@ -46,7 +47,16 @@ test: contrib/shunit2/shunit2 ## Run the acceptance tests for steps done; \ done; -clean: ## Clean all temporary/working files +migrate: $(SQLITE_DB) ## Run the local SQLite migrations + sqlx migrate --source migrations/sqlite run + +$(SQLITE_DB): ## Create an empty SQLite database + sqlx database create + +clean-db: ## Remove the SQLite database for local development + rm -f $(SQLITE_DB) + +clean: clean-db ## Clean all temporary/working files diagram: system.png system.dot ## Generate the diagrams describing otto dot -Tpng -o system.png system.dot diff --git a/migrations/sqlite/20210303191923_projects.sql b/migrations/sqlite/20210303191923_projects.sql index 71cfbc5..ef92bcd 100644 --- a/migrations/sqlite/20210303191923_projects.sql +++ b/migrations/sqlite/20210303191923_projects.sql @@ -6,11 +6,13 @@ CREATE TABLE IF NOT EXISTS projects ( uuid BLOB PRIMARY KEY NOT NULL, - path TEXT NOT NULL, + path TEXT UNIQUE NOT NULL, title TEXT NOT NULL, description TEXT, source_url TEXT, source_refspec TEXT, pipeline_path TEXT, - pipeline_inline TEXT + pipeline_inline TEXT, + created_at DATETIME DEFAULT (DATETIME('now')), + last_updated_at DATETIME DEFAULT (DATETIME('now')) );