salix/db/changes/10100-allSaints/01-userPhone.sql

24 lines
592 B
SQL

CREATE TABLE `vn`.`userPhone` (
`id` INT NOT NULL AUTO_INCREMENT,
`userFk` INT(10) UNSIGNED NOT NULL,
`typeFk` VARCHAR(45) NOT NULL,
`phone` VARCHAR(25) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `UserFk_Phone` (`userFk` ASC, `typeFk` ASC, `phone` ASC));
ALTER TABLE `vn`.`userPhone`
ADD CONSTRAINT `fgnTypeFk`
FOREIGN KEY (typeFk)
REFERENCES `vn`.`userPhoneType` (code)
ON DELETE RESTRICT
ON UPDATE CASCADE;
ALTER TABLE `vn`.`userPhone`
ADD CONSTRAINT `fgnUserFk`
FOREIGN KEY (userFk)
REFERENCES `account`.`user` (id)
ON DELETE CASCADE
ON UPDATE CASCADE;