002.sql 480 B

123456789101112131415
  1. -- Crea la tabla de las notas de los usuarios.
  2. CREATE TABLE IF NOT EXISTS notes (
  3. id CHAR(36) NOT NULL,
  4. user_id CHAR(36) NOT NULL,
  5. title VARCHAR(255) NOT NULL,
  6. body TEXT NOT NULL,
  7. created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  8. updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  9. CONSTRAINT notes_id_primary PRIMARY KEY(id),
  10. CONSTRAINT notes_user_id_foreign FOREIGN KEY(user_id)
  11. REFERENCES users(id)
  12. ON DELETE CASCADE
  13. ON UPDATE RESTRICT
  14. );