Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add migration for D1 table creation
Browse files Browse the repository at this point in the history
- Worker would throw exception if deployed before table was created
maxwellpeterson committed Jan 23, 2025
1 parent 2ab6cfd commit d1954a8
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions d1-template/migrations/0001_create_comments_table.sql
Original file line number Diff line number Diff line change
@@ -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!')
;
1 change: 1 addition & 0 deletions d1-template/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}

0 comments on commit d1954a8

Please sign in to comment.