diff --git a/d1-template/migrations/0001_create_comments_table.sql b/d1-template/migrations/0001_create_comments_table.sql new file mode 100644 index 00000000..5ba9353a --- /dev/null +++ b/d1-template/migrations/0001_create_comments_table.sql @@ -0,0 +1,14 @@ +-- Migration number: 0001 2024-12-27T22:04:18.794Z +CREATE TABLE IF NOT EXISTS comments ( + id INTEGER PRIMARY KEY NOT NULL, + author TEXT NOT NULL, + content TEXT NOT NULL +); + +-- Insert some sample data into our comments table. +INSERT INTO comments (author, content) +VALUES + ('Kristian', 'Congrats!'), + ('Serena', 'Great job!'), + ('Max', 'Keep up the good work!') +; diff --git a/d1-template/package.json b/d1-template/package.json index 3271cb9a..019c5963 100644 --- a/d1-template/package.json +++ b/d1-template/package.json @@ -26,6 +26,7 @@ "check": "tsc && wrangler --experimental-json-config deploy --dry-run", "deploy": "wrangler --experimental-json-config deploy", "dev": "wrangler --experimental-json-config dev", + "predeploy": "wrangler --experimental-json-config d1 migrations apply d1-template-database --remote", "types": "wrangler --experimental-json-config types" } }