fix: exclude all cf tables in empty-db detection query
This commit is contained in:
parent
62a36acbb6
commit
59ddb23a83
3 changed files with 6 additions and 4 deletions
4
.github/workflows/deploy-dev.yaml
vendored
4
.github/workflows/deploy-dev.yaml
vendored
|
|
@ -114,10 +114,10 @@ jobs:
|
|||
WRANGLER="npx --yes wrangler@${WRANGLER_VERSION}"
|
||||
|
||||
TABLE_COUNT=$($WRANGLER d1 execute vault1 --env dev --remote --command \
|
||||
"SELECT COUNT(*) AS cnt FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' AND name NOT IN ('_cf_METADATA','d1_migrations');" \
|
||||
"SELECT COUNT(*) AS cnt FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' AND name NOT LIKE '_cf_%' AND name NOT IN ('d1_migrations');" \
|
||||
--json | jq -r '.[0].results[0].cnt // 0')
|
||||
|
||||
echo "Existing user table count: ${TABLE_COUNT}"
|
||||
echo "Existing app table count: ${TABLE_COUNT}"
|
||||
if [ "${TABLE_COUNT}" = "0" ]; then
|
||||
echo "🆕 Empty D1 database detected; applying sql/schema.sql..."
|
||||
$WRANGLER d1 execute vault1 --env dev --remote --file sql/schema.sql
|
||||
|
|
|
|||
4
.github/workflows/push-cloudflare.yaml
vendored
4
.github/workflows/push-cloudflare.yaml
vendored
|
|
@ -124,10 +124,10 @@ jobs:
|
|||
WRANGLER="npx --yes wrangler@${WRANGLER_VERSION}"
|
||||
|
||||
TABLE_COUNT=$($WRANGLER d1 execute vault1 --remote --command \
|
||||
"SELECT COUNT(*) AS cnt FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' AND name NOT IN ('_cf_METADATA','d1_migrations');" \
|
||||
"SELECT COUNT(*) AS cnt FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' AND name NOT LIKE '_cf_%' AND name NOT IN ('d1_migrations');" \
|
||||
--json | jq -r '.[0].results[0].cnt // 0')
|
||||
|
||||
echo "Existing user table count: ${TABLE_COUNT}"
|
||||
echo "Existing app table count: ${TABLE_COUNT}"
|
||||
if [ "${TABLE_COUNT}" = "0" ]; then
|
||||
echo "🆕 Empty D1 database detected; applying sql/schema.sql..."
|
||||
$WRANGLER d1 execute vault1 --remote --file sql/schema.sql
|
||||
|
|
|
|||
|
|
@ -92,6 +92,8 @@ keep_vars = true
|
|||
workers_dev = false
|
||||
preview_urls = false
|
||||
|
||||
[env.dev.vars]
|
||||
|
||||
[env.dev.durable_objects]
|
||||
bindings = [
|
||||
{ name = "HEAVY_DO", class_name = "HeavyDo" }
|
||||
|
|
|
|||
Loading…
Reference in a new issue