Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions mysql-hyperdrive-template/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,14 @@ async function handleApiRequest(
)
`);

// Create users table with foreign key
// Create users table (no foreign key for Vitess compatibility)
await connection.query(`
CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) NOT NULL,
organization_id INT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (organization_id) REFERENCES organizations(id) ON DELETE SET NULL
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)
`);

Expand Down
2 changes: 1 addition & 1 deletion mysql-hyperdrive-template/wrangler.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"hyperdrive": [
{
"binding": "HYPERDRIVE",
"id": "7668c461af3c47969772c19cbd988391",
"id": "7668c461af3c47969772c19cbd988391", // Replace with your Hyperdrive ID
"localConnectionString": "mysql://username:password@mysql-domain.com:3306/defaultdb" // Replace with your connection string
}
],
Expand Down