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
This commit is contained in:
R Tyler Croy 2021-03-03 11:24:21 -08:00
parent f017ea4660
commit 8a1a47669c
6 changed files with 21 additions and 1 deletions

1
.env Normal file
View File

@ -0,0 +1 @@
DATABASE_URL=sqlite:otto.db

1
.gitignore vendored
View File

@ -8,3 +8,4 @@ build/
*.tar.gz
tmp*
.hypothesis/
otto.db

1
Cargo.lock generated
View File

@ -2937,6 +2937,7 @@ dependencies = [
"stringprep",
"thiserror",
"url",
"uuid",
"webpki",
"webpki-roots",
"whoami",

View File

@ -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
);

1
services/reldata/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
target/

View File

@ -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"