manubier
Explore posts from serversCDCloudflare Developers
•Created by manubier on 10/11/2024 in #general-help
Seeking Best Practices for Using Drizzle ORM with D1, Especially for Migrations
Ok, I just prayed, removed the comment and ran the thing against production. It worked. So it seems the comment in the beginning of the migration file is a problem for wrangler when running it with the --remote flag.
5 replies
CDCloudflare Developers
•Created by manubier on 10/11/2024 in #general-help
Seeking Best Practices for Using Drizzle ORM with D1, Especially for Migrations
Here is the migration file. The comment on top is weird to me because I have generated columns with the same settings before.
/*
SQLite does not support "Set default to column" out of the box, we do not generate automatic migration for that, so it has to be done manually
Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
https://www.sqlite.org/lang_altertable.html
https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
Due to that we don't generate migration automatically and it has to be done manually
*/--> statement-breakpoint
ALTER TABLE
candidate_checks
ADD candidate_category
text DEFAULT 'NO_FIT';--> statement-breakpoint
ALTER TABLE candidate_checks
ADD is_favorite
integer DEFAULT false NOT NULL;5 replies
CDCloudflare Developers
•Created by manubier on 10/11/2024 in #general-help
Seeking Best Practices for Using Drizzle ORM with D1, Especially for Migrations
Here is more info about the migration that runs smooth on my local db and fails on D1.
Console Logs:
├───────────────────────────────────┤
│ 0002_third_carmella_unuscione.sql │
└───────────────────────────────────┘
✔ About to apply 1 migration(s)
Your database may not be available to serve requests during the migration, continue? … yes
🌀 Executing on remote database prod-talentsourcer-ai-v2 (86f547dc-d0b2-456b-a369-604c409423fc):
🌀 To execute on your local development database, remove the --remote flag from your wrangler command.
┌───────────────────────────────────┬────────┐
│ name │ status │
├───────────────────────────────────┼────────┤
│ 0002_third_carmella_unuscione.sql │ ❌ │
└───────────────────────────────────┴────────┘
❌ Migration 0002_third_carmella_unuscione.sql failed with the following errors:
✘ [ERROR] A prepared SQL statement must contain only one statement. [code: 7500]
Happy to share full logs in DM.
5 replies
DTDrizzle Team
•Created by Gabriel Lucena on 5/31/2024 in #help
Help querying D1 with Drizzle
I followed these steps and ran into the following situation:
1. I recently encountered a situation where a migration applied successfully locally but failed when I tried to apply it in production.
2. Additionally, Wrangler doesn’t seem to have a command for dropping migrations. I used Drizzle drop, but since the initial application was through Wrangler, it didn’t properly adjust my local database. This left my local database in an odd state.
Anyone has good advice on how to solve this?
Also any advice on how to properly seed the local db? I created a script which uses the d1 API to seed prod but not sure how to do it locally.
9 replies