-
Notifications
You must be signed in to change notification settings - Fork 0
/
dump.sql
7 lines (7 loc) · 1.53 KB
/
dump.sql
1
2
3
4
5
6
7
CREATE TABLE site (id INT AUTO_INCREMENT NOT NULL, domain VARCHAR(250) NOT NULL, token VARCHAR(60) NOT NULL, created DATETIME NOT NULL, updated DATETIME DEFAULT NULL, INDEX domain (domain), INDEX created (created), UNIQUE INDEX site_domain (token), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB;
CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, email VARCHAR(100) NOT NULL, UNIQUE INDEX mail (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB;
CREATE TABLE user_reaction (id INT AUTO_INCREMENT NOT NULL, object INT DEFAULT NULL, user INT DEFAULT NULL, stars INT NOT NULL, comment LONGTEXT NOT NULL, INDEX object (object), INDEX user (user), INDEX stars (stars), UNIQUE INDEX user_object (user, object), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB;
CREATE TABLE site_object (id INT AUTO_INCREMENT NOT NULL, site INT DEFAULT NULL, url LONGTEXT NOT NULL, hash VARCHAR(60) NOT NULL, INDEX IDX_D80305B3694309E4 (site), INDEX hash (hash), UNIQUE INDEX site_object (site, hash), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB;
ALTER TABLE user_reaction ADD CONSTRAINT FK_445AE3F7A8ADABEC FOREIGN KEY (object) REFERENCES site_object (id) ON DELETE CASCADE;
ALTER TABLE user_reaction ADD CONSTRAINT FK_445AE3F78D93D649 FOREIGN KEY (user) REFERENCES user (id) ON DELETE CASCADE;
ALTER TABLE site_object ADD CONSTRAINT FK_D80305B3694309E4 FOREIGN KEY (site) REFERENCES site (id) ON DELETE CASCADE;