003.sql 525 B

123456789101112131415
  1. -- Crea la tabla de los tags de los usuarios.
  2. CREATE TABLE IF NOT EXISTS tags (
  3. id CHAR(36) NOT NULL,
  4. user_id CHAR(36) NOT NULL,
  5. name VARCHAR(64) NOT NULL,
  6. created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  7. updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  8. CONSTRAINT tags_id_primary PRIMARY KEY(id),
  9. CONSTRAINT tags_user_id_foreign FOREIGN KEY(user_id)
  10. REFERENCES users(id)
  11. ON DELETE CASCADE
  12. ON UPDATE RESTRICT,
  13. CONSTRAINT tags_user_id_name_unique UNIQUE(user_id, name)
  14. );