File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111 runs-on : ubuntu-latest
1212 steps :
1313 - uses : actions/checkout@v4
14- - uses : cloudflare/wrangler-action@v3
14+
15+ - name : Setup Node.js
16+ uses : actions/setup-node@v4
17+ with :
18+ node-version : ' 20'
19+
20+ - name : Install Wrangler
21+ run : npm install -g wrangler
22+
23+ - name : Run D1 Migrations
24+ working-directory : website
25+ env :
26+ CLOUDFLARE_API_TOKEN : ${{ secrets.CLOUDFLARE_API_TOKEN }}
27+ CLOUDFLARE_ACCOUNT_ID : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
28+ run : |
29+ # Apply all migrations in order
30+ for migration in migrations/*.sql; do
31+ if [ -f "$migration" ]; then
32+ echo "Applying migration: $migration"
33+ wrangler d1 execute openboot --remote --file="$migration" || true
34+ fi
35+ done
36+
37+ - name : Deploy Worker
38+ uses : cloudflare/wrangler-action@v3
1539 with :
1640 apiToken : ${{ secrets.CLOUDFLARE_API_TOKEN }}
1741 accountId : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
Original file line number Diff line number Diff line change 1+ -- Migration: 0001_init
2+ -- Created: 2024-02-01
3+
4+ CREATE TABLE IF NOT EXISTS users (
5+ id TEXT PRIMARY KEY ,
6+ username TEXT UNIQUE NOT NULL ,
7+ email TEXT ,
8+ avatar_url TEXT ,
9+ created_at TEXT DEFAULT (datetime(' now' )),
10+ updated_at TEXT DEFAULT (datetime(' now' ))
11+ );
12+
13+ CREATE TABLE IF NOT EXISTS configs (
14+ id TEXT PRIMARY KEY ,
15+ user_id TEXT NOT NULL ,
16+ slug TEXT NOT NULL ,
17+ name TEXT NOT NULL ,
18+ description TEXT ,
19+ base_preset TEXT DEFAULT ' developer' ,
20+ packages TEXT ,
21+ custom_script TEXT ,
22+ is_public INTEGER DEFAULT 1 ,
23+ created_at TEXT DEFAULT (datetime(' now' )),
24+ updated_at TEXT DEFAULT (datetime(' now' )),
25+ FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ,
26+ UNIQUE(user_id, slug)
27+ );
28+
29+ CREATE INDEX IF NOT EXISTS idx_configs_user_id ON configs(user_id);
30+ CREATE INDEX IF NOT EXISTS idx_users_username ON users(username);
Original file line number Diff line number Diff line change 1+ -- Migration: 0002_add_alias
2+ -- Created: 2024-02-01
3+ -- Note: SQLite doesn't support "IF NOT EXISTS" for ALTER TABLE ADD COLUMN
4+ -- This migration may fail if already applied - that's expected behavior
5+
6+ -- Add alias column (will fail if exists - that's OK)
7+ ALTER TABLE configs ADD COLUMN alias TEXT UNIQUE;
8+
9+ -- Create index (idempotent)
10+ CREATE INDEX IF NOT EXISTS idx_configs_alias ON configs(alias);
Original file line number Diff line number Diff line change @@ -13,3 +13,4 @@ directory = "."
1313binding = " DB"
1414database_name = " openboot"
1515database_id = " 6faf0c13-b182-4dca-bf13-ec346d085960"
16+ migrations_dir = " migrations"
You can’t perform that action at this time.
0 commit comments