Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add drip db #44

Merged
merged 10 commits into from
Aug 27, 2023
38 changes: 19 additions & 19 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"start": "wrangler dev --remote"
},
"devDependencies": {
"wrangler": "^3.5.1"
"wrangler": "^3.6.0"
}
}
6 changes: 6 additions & 0 deletions backend/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ workers_dev = true
r2_buckets = [
{ binding = "BLOG_BUCKET", bucket_name = "flinnlab-blog-dev" }
]
d1_databases = [
{ binding = "DB", database_name = "blog-drip-dev", database_id = "d898dfc0-f641-425c-8c6a-e25da2cf7468", migrations_dir = "../data/drip-db/migrations" }
]

[env.staging.vars]
FLAG_USE_HEADERS=true
Expand All @@ -36,6 +39,9 @@ workers_dev = true
r2_buckets = [
{ binding = "BLOG_BUCKET", bucket_name = "flinnlab-blog" }
]
d1_databases = [
{ binding = "DB", database_name = "blog-drip", database_id = "b8dc883c-78e0-4687-bfe2-45401ae32813", migrations_dir = "../data/databases/blog-drip/migrations" }
]

[env.production.vars]
FLAG_USE_HEADERS=true
23 changes: 23 additions & 0 deletions data/databases/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# https://taskfile.dev

version: '3'

tasks:
test:clean:
dir: ./tests/
cmds:
- |
for f in $(ls finalization_migrations); do
rm $f
done

echo "cleaned tests/finalization_migrations"
- |
for f in $(ls migrations); do
if [[ $(basename $f) =~ "world" ]]; then
rm $f
fi
done
echo "cleaned tests/migraitons"
silent: true

9 changes: 9 additions & 0 deletions data/databases/blog-drip/migrations/0000_init_migrator.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- Migration number: 0000 2023-08-26T21:39:45.337Z

CREATE TABLE IF NOT EXISTS eddm_migrations (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT UNIQUE,
applied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
);

INSERT INTO eddm_migrations (name) values ('0000_init_migrator.sql');
15 changes: 15 additions & 0 deletions data/databases/blog-drip/migrations/0001_create_drip.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- Migration number: 0001 2023-08-26T21:49:40.373Z


CREATE TABLE IF NOT EXISTS drip (
id INTEGER PRIMARY KEY AUTOINCREMENT,
message TEXT NOT NULL,
tags JSON,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
);



-- DO NOT REMOVE --
INSERT INTO eddm_migrations (name) values ('0001_create_drip.sql');
Loading