SQL

CREATE TABLE human_notification_stats  (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  chatbot_id INTEGER NOT NULL,
  user_id INTEGER NOT NULL,
  notification_id INTEGER NOT NULL,
  notification_method TEXT NOT NULL,
  created_at TEXT NOT NULL,
  FOREIGN KEY (chatbot_id) REFERENCES chatbots(id) ON DELETE CASCADE,
  FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
  FOREIGN KEY (notification_id) REFERENCES notifications(id) ON DELETE CASCADE
)

+ Add column

Columns

Column Data type Allow null Primary key Actions
id INTEGER Rename | Drop
chatbot_id INTEGER Rename | Drop
user_id INTEGER Rename | Drop
notification_id INTEGER Rename | Drop
notification_method TEXT Rename | Drop
created_at TEXT Rename | Drop

Foreign Keys

Column Destination
notification_id notifications.id
user_id users.id
chatbot_id chatbots.id

+ Add index

Indexes

Name Columns Unique SQL Drop?
idx_human_notification_stats_chatbot_user
  • chatbot_id
  • user_id
SQL
CREATE INDEX idx_human_notification_stats_chatbot_user
ON human_notification_stats(chatbot_id, user_id)
Drop
idx_human_notification_stats_created_at created_at SQL
CREATE INDEX idx_human_notification_stats_created_at
ON human_notification_stats(created_at)
Drop