nuxt-hub / core

Build full-stack applications with Nuxt on CloudFlare, with zero configuration.
https://hub.nuxt.com
Apache License 2.0
993 stars 57 forks source link

Database - Create Trigger #372

Open Brianelvio opened 2 weeks ago

Brianelvio commented 2 weeks ago

Describe the bug When trying to create a trigger the migration will always fail.

My attempt:

CREATE TRIGGER update_users_timestamp 
AFTER UPDATE ON users
BEGIN
  UPDATE users SET updated_at = CURRENT_TIMESTAMP WHERE id = NEW.id;
END;

Error:

 ERROR  Failed to apply migration ./server/database/migrations/0002_adduserstimestamptrigger.sql
 D1_ERROR: incomplete input: SQLITE_ERROR

Steps to reproduce Steps to reproduce the behavior:

  1. Create a migration
  2. Try to create a trigger
  3. Run the migration
  4. See error

Expected behavior Migration is able to handle triggers for SQLite.

atinux commented 1 week ago

Could you try to put all your statement in one line?