D1使用说明文档:Getting started · Cloudflare D1 docs
如果想在已存在的表中添加字端,可以直接在sql中添加,然后想设置默认值也可以:Country TEXT DEFAULT 'China' 就可以了
然后再次执行合并数据库和查看里面的数据:
npx wrangler d1 execute prod-d1-tutorial --local --file=./migrations/schema.sql
npx wrangler d1 execute prod-d1-tutorial --local --command="SELECT * FROM Customers"
可以看到能查到这些数据:
如果没有问题,就可以同步到远程:
npx wrangler d1 execute prod-d1-tutorial --remote --file=./migrations/schema.sql
npx wrangler d1 execute prod-d1-tutorial --remote --command="SELECT * FROM Customers"
同步之后,也可以看到数据已经变了:
在cloudflare中也可以看到这些数据: