salix/db/versions/.archive/10277-azurePalmetto/00-firstScript.sql

13 lines
504 B
SQL

-- Place your SQL code here
USE vn;
CREATE OR REPLACE TABLE `operator` (
`workerFk` int(10) unsigned NOT NULL,
`numberOfWagons` int(11) DEFAULT 1,
PRIMARY KEY (`workerFk`),
KEY `operator_FK` (`workerFk`),
CONSTRAINT `operator_FK` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
INSERT INTO vn.operator (workerFk, numberOfWagons)
SELECT id, 2 FROM vn.worker WHERE sectorFk is not null;