Does D1 support triggers? Whenever I try to run the migration with --remote to create a trigger, I

Does D1 support triggers? Whenever I try to run the migration with --remote to create a trigger, I get "X [ERROR] incomplete input: SQLITE_ERROR [code: 7500]" Example code of what I am trying to run is like this

-- Create a simple table
DROP TABLE IF EXISTS test_table;

CREATE TABLE IF NOT EXISTS test_table (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT,
    updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

-- Drop any existing trigger
DROP TRIGGER IF EXISTS test_trigger;

-- Create a simple trigger
CREATE TRIGGER test_trigger
AFTER UPDATE ON test_table
FOR EACH ROW
BEGIN
  UPDATE test_table
  SET updated_at = CURRENT_TIMESTAMP
  WHERE id = OLD.id;
END;
Was this page helpful?