From 8a1a47669c89b147e7b08133289025c685a31e95 Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Wed, 3 Mar 2021 11:24:21 -0800 Subject: [PATCH] Scaffolding up reldata service's data migrations Right now I'm just working within sqlite, but the migrations will need to be mirrored for PostgreSQL in the future in `migrations/postgres` Running this entails using the sqlx-cli (`cargo install sqlx-cli`) % sqlx migrate --source migrations/sqlite run --- .env | 1 + .gitignore | 1 + Cargo.lock | 1 + migrations/sqlite/20210303191923_projects.sql | 16 ++++++++++++++++ services/reldata/.gitignore | 1 + services/reldata/Cargo.toml | 2 +- 6 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 .env create mode 100644 migrations/sqlite/20210303191923_projects.sql create mode 100644 services/reldata/.gitignore diff --git a/.env b/.env new file mode 100644 index 0000000..adcd6d3 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +DATABASE_URL=sqlite:otto.db diff --git a/.gitignore b/.gitignore index 31e9322..3390433 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ build/ *.tar.gz tmp* .hypothesis/ +otto.db diff --git a/Cargo.lock b/Cargo.lock index a64c1e0..1f0d1e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2937,6 +2937,7 @@ dependencies = [ "stringprep", "thiserror", "url", + "uuid", "webpki", "webpki-roots", "whoami", diff --git a/migrations/sqlite/20210303191923_projects.sql b/migrations/sqlite/20210303191923_projects.sql new file mode 100644 index 0000000..71cfbc5 --- /dev/null +++ b/migrations/sqlite/20210303191923_projects.sql @@ -0,0 +1,16 @@ +-- +-- This migration adds the projects table which should be largely populated out +-- of the projects.d directory + + +CREATE TABLE IF NOT EXISTS projects +( + uuid BLOB PRIMARY KEY NOT NULL, + path TEXT NOT NULL, + title TEXT NOT NULL, + description TEXT, + source_url TEXT, + source_refspec TEXT, + pipeline_path TEXT, + pipeline_inline TEXT +); diff --git a/services/reldata/.gitignore b/services/reldata/.gitignore new file mode 100644 index 0000000..2f7896d --- /dev/null +++ b/services/reldata/.gitignore @@ -0,0 +1 @@ +target/ diff --git a/services/reldata/Cargo.toml b/services/reldata/Cargo.toml index bd3d92c..a785166 100644 --- a/services/reldata/Cargo.toml +++ b/services/reldata/Cargo.toml @@ -11,5 +11,5 @@ async-std = { version = "1", features = ["attributes"]} log = "~0.4.11" otto-models = { path = "../../crates/models" } pretty_env_logger = "~0.4.0" -sqlx = { version = "~0.5.1", features = ["runtime-async-std-rustls", "postgres", "tls", "json", "sqlite", "chrono", "macros"]} +sqlx = { version = "~0.5.1", features = ["runtime-async-std-rustls", "postgres", "tls", "json", "sqlite", "chrono", "macros", "uuid"]} tide = "~0.15.0"