cloudflare / cloudflare/developer-platform

🐛 BUG: `[7501]` error after a successfully complete migration...

Đang mở
#39 8 bình luận 0 reaction 0 người được giao Xem trên GitHub
product:d1
Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
1
Fork
0
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

### Which Cloudflare product(s) does this pertain to?

D1

### What version of `Wrangler` are you using?

3.1.0

### What operating system are you using?

Linux (ubuntu-latest/github-actions)

### Describe the Bug

I have got a strange error when running migrations on recently created, empty D1 database. Both migrations listed below where applied and I can confirm it inspecting the database. All required tables were created with right types and right indexes, however I still got an error telling otherwise.

After rerunning the action manually, the migrations status was confirmed as already applies and no further migrations were run: `✅ No migrations to apply!`.

Here is the run logs, from the point of applying the migrations:
```
Run pnpm run db.apply
pnpm run db.apply
shell: /usr/bin/bash -e {0}
env:
PNPM_HOME: /home/runner/setup-pnpm/node_modules/.bin
CLOUDFLARE_API_TOKEN: ***

> @*****/*****@ db.apply /home/runner/work/*****/*****/apps/*****/*****
> wrangler d1 migrations apply blog

▲ [WARNING] Processing wrangler.toml configuration:

- D1 Bindings are currently in alpha to allow the API to evolve before general availability.
Please report any issues to https://github.com/cloudflare/workers-sdk/issues/new/choose
Note: Run this command with the environment variable NO_D1_WARNING=true to hide this message

For example: `export NO_D1_WARNING=true && wrangler `

--------------------
🚧 D1 is currently in open alpha and is not recommended for production data and traffic
🚧 Please report any bugs to https://github.com/cloudflare/workers-sdk/issues/new/choose
🚧 To request features, visit https://community.cloudflare.com/c/developers/d1
🚧 To give feedback, visit https://discord.gg/cloudflaredev
--------------------

Migrations to be applied:
┌────────────────────────────┐
│ name │
├────────────────────────────┤
│ 0000_panoramic_sleeper.sql │
├────────────────────────────┤
│ 0001_melodic_sentry.sql │
└────────────────────────────┘
? About to apply [2](https://github.com/*****/*****/actions/runs/*****/jobs/*****#step:*****) migration(s)
Your database may not be available to serve requests during the migration, continue?
🤖 Using default value in non-interactive context: yes
🕒 Creating backup...
🌀 Mapping SQL input into an array of statements
🌀 Parsing 4 statements
🌀 Executing on *****(ede788c4-771d-410a-91[3](https://github.com/*****/*****/actions/runs/*****/jobs/*****#step:*****)0-[4](https://github.com/*****/*****/actions/runs/*****/jobs/*****#step:*****)fefd3788ab[5](https://github.com/*****/*****/actions/runs/*****/jobs/*****#step:*****)):
🚣 Executed 4 commands in 21.27123999595[6](https://github.com/*****/*****/actions/runs/*****/jobs/*****#step:*****)42ms
┌────────────────────────────┬────────┐
│ name │ status │
├────────────────────────────┼────────┤
│ 0000_*****_*****.sql │ ✅ │
├────────────────────────────┼────────┤
│ 0001_*****_*****.sql │ 🕒️ │
└────────────────────────────┴────────┘
🌀 Mapping SQL input into an array of statements
🌀 Parsing 4 statements
🌀 Executing on blog (ede[7](https://github.com/*****/*****/actions/runs/*****/jobs/*****#step:*****)[8](https://github.com/*****/*****/actions/runs/*****/jobs/*****#step:*****)8c4-771d-410a-[9](https://github.com/*****/*****/actions/runs/*****/jobs/*****#step:*****)130-4fefd3788ab5):
┌────────────────────────────┬────────┐
│ name │ status │
├────────────────────────────┼────────┤
│ 0000_*****_*****.sql │ ✅ │
├────────────────────────────┼────────┤
│ 0001_*****_*****.sql │ ❌ │
└────────────────────────────┴────────┘

❌ Migration 0001_*****_*****.sql failed with the following errors:

✘ [ERROR] Internal error: Error sending request to D1 for database ede788c4-771d-4[10](https://github.com/*****/*****/actions/runs/*****/jobs/*****#step:*****)a-9130-4fefd3788ab5 [code: 7501]

If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose
 ELIFECYCLE  Command failed with exit code 1.
Error: Process completed with exit code 1.
```

0001_*****_*****.sql
```sql
CREATE TABLE `emails` (
`id` integer PRIMARY KEY NOT NULL,
`email` text(320) NOT NULL,
`token` text(21) NOT NULL,
`timestamp` integer NOT NULL
);

CREATE UNIQUE INDEX `idx_unique_token` ON `emails` (`token`);
CREATE UNIQUE INDEX `idx_unique_email` ON `emails` (`email`);
```

0002_*****_*****.sql
```sql
CREATE TABLE `access.access` (
`id` integer PRIMARY KEY NOT NULL,
`ipid` integer NOT NULL,
`timestamp` integer NOT NULL,
FOREIGN KEY (`ipid`) REFERENCES `access.ips`(`id`)
);

CREATE TABLE `access.ips` (
`id` integer PRIMARY KEY NOT NULL,
`ip` text(45) NOT NULL,
`type` text NOT NULL
);

CREATE UNIQUE INDEX `idx_unique_ip` ON `access.ips` (`ip`);
```

Running `SELECT name, type, sql FROM sqlite_schema;` gives:

name | type | sql
-- | -- | --
d1_kv | table | CREATE TABLE d1_kv (key TEXT PRIMARY KEY, value TEXT NOT NULL)
sqlite_autoindex_d1_kv_1 | index |
__drizzle_migrations | table | CREATE TABLE __drizzle_migrations( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT UNIQUE, applied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL )
sqlite_autoindex___drizzle_migrations_1 | index |
sqlite_sequence | table | CREATE TABLE sqlite_sequence(name,seq)
emails | table | CREATE TABLE `emails` ( `id` integer PRIMARY KEY NOT NULL, `email` text(320) NOT NULL, `token` text(21) NOT NULL, `timestamp` integer NOT NULL )
idx_unique_token | index | CREATE UNIQUE INDEX `idx_unique_token` ON `emails` (`token`)
idx_unique_email | index | CREATE UNIQUE INDEX `idx_unique_email` ON `emails` (`email`)
access.access | table | CREATE TABLE `access.access` ( `id` integer PRIMARY KEY NOT NULL, `ipid` integer NOT NULL, `timestamp` integer NOT NULL, FOREIGN KEY (`ipid`) REFERENCES `access.ips`(`id`) )
access.ips | table | CREATE TABLE `access.ips` ( `id` integer PRIMARY KEY NOT NULL, `ip` text(45) NOT NULL, `type` text NOT NULL )
idx_unique_ip | index | CREATE UNIQUE INDEX `idx_unique_ip` ON `access.ips` (`ip`)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với đường dẫn `wrangler d1 migrations apply` bằng cách sử dụng Wrangler 3.1.0 và hai ví dụ migration SQL trong báo cáo. So sánh lỗi code 7501 được báo cáo với các entry kết quả trong `sqlite_schema` và `__drizzle_migrations`; được xem là hoàn tất khi giải thích hoặc sửa được trường hợp migration đã được áp dụng nhưng lệnh vẫn kết thúc với lỗi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
sql
Lĩnh vực
databases
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.