salix/db/versions/10799-limePalmetto/00-firstScript.sql

28 lines
958 B
SQL

ALTER TABLE vn.routeCommission DROP FOREIGN KEY IF EXISTS routeCommission_firstEditorFk;
ALTER TABLE vn.routeCommission DROP COLUMN IF EXISTS firstEditorFk;
ALTER TABLE vn.route DROP FOREIGN KEY IF EXISTS route_firstEditorFk;
ALTER TABLE vn.route DROP COLUMN IF EXISTS firstEditorFk;
ALTER TABLE vn.route
ADD firstEditorFk INTEGER UNSIGNED NOT NULL
COMMENT 'Usuario creador de la ruta' AFTER workerFk;
ALTER TABLE vn.routeCommission
ADD firstEditorFk INTEGER UNSIGNED NOT NULL
COMMENT 'Usuario creador de la ruta' AFTER workCenterFk;
UPDATE vn.routeCommission rc
JOIN vn.routeLog rl ON rl.originFk = rc.routeFk
SET rc.firstEditorFk = rl.userFk
WHERE rl.`action` = 'insert';
UPDATE vn.routeCommission rc
SET firstEditorFk = 4365
WHERE routeFk = 125360;
ALTER TABLE vn.routeCommission
ADD CONSTRAINT routeCommission_firstEditorFk FOREIGN KEY (firstEditorFk)
REFERENCES account.user(id) ON DELETE CASCADE ON UPDATE CASCADE;