80.sql (667B)
1 -- +migrate Up 2 CREATE TABLE IF NOT EXISTS notifications ( 3 id INTEGER NOT NULL PRIMARY KEY, 4 user_id INTEGER NOT NULL, 5 message TEXT NOT NULL, 6 is_read TINYINT(1) NOT NULL DEFAULT 0, 7 read_at DATETIME NULL, 8 created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, 9 CONSTRAINT notifications_user_id_fk 10 FOREIGN KEY (user_id) 11 REFERENCES users (id) 12 ON DELETE CASCADE 13 ON UPDATE CASCADE); 14 CREATE INDEX notifications_user_id_idx ON notifications (user_id); 15 CREATE INDEX notifications_is_read_idx ON notifications (is_read); 16 CREATE INDEX notifications_read_at_idx ON notifications (read_at); 17 18 -- +migrate Down