-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove citizenId & plate from vehicle_financing
- Loading branch information
1 parent
e915a95
commit 4050726
Showing
4 changed files
with
49 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,20 @@ | ||
CREATE TABLE IF NOT EXISTS `vehicle_financing` ( | ||
`vehicleId` int(11) NOT NULL, | ||
`citizenid` varchar(50) NOT NULL, | ||
`plate` varchar(15) NOT NULL, | ||
`balance` int(11) DEFAULT NULL, | ||
`paymentamount` int(11) DEFAULT NULL, | ||
`paymentsleft` int(11) DEFAULT NULL, | ||
`financetime` int(11) DEFAULT NULL, | ||
PRIMARY KEY (`vehicleId`), | ||
FOREIGN KEY `vehicleId` (`vehicleId`) REFERENCES `player_vehicles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, | ||
FOREIGN KEY `plate` (`plate`) REFERENCES `player_vehicles` (`plate`) ON DELETE CASCADE ON UPDATE CASCADE, | ||
FOREIGN KEY `citizenid` (`citizenid`) REFERENCES `players` (`citizenid`) ON DELETE CASCADE ON UPDATE CASCADE | ||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; | ||
|
||
INSERT INTO vehicle_financing (citizenid, plate, balance, paymentamount, paymentsleft, financetime) | ||
SELECT citizenid, plate, balance, paymentamount, paymentsleft, financetime | ||
INSERT INTO vehicle_financing (vehicleId, balance, paymentamount, paymentsleft, financetime) | ||
SELECT id, balance, paymentamount, paymentsleft, financetime | ||
FROM player_vehicles | ||
WHERE balance > 0 OR paymentamount > 0 OR paymentsleft > 0 OR financetime > 0; | ||
|
||
ALTER TABLE player_vehicles | ||
DROP COLUMN balance, | ||
DROP COLUMN paymentamount, | ||
DROP COLUMN paymentsleft, | ||
DROP COLUMN financetime; | ||
DROP COLUMN financetime; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
CREATE TABLE IF NOT EXISTS `vehicle_financing` ( | ||
`vehicleId` int(11) NOT NULL, | ||
`citizenid` varchar(50) NOT NULL, | ||
`plate` varchar(15) NOT NULL, | ||
`balance` int(11) DEFAULT NULL, | ||
`paymentamount` int(11) DEFAULT NULL, | ||
`paymentsleft` int(11) DEFAULT NULL, | ||
`financetime` int(11) DEFAULT NULL, | ||
PRIMARY KEY (`vehicleId`), | ||
FOREIGN KEY `vehicleId` (`vehicleId`) REFERENCES `player_vehicles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, | ||
FOREIGN KEY `plate` (`plate`) REFERENCES `player_vehicles` (`plate`) ON DELETE CASCADE ON UPDATE CASCADE, | ||
FOREIGN KEY `citizenid` (`citizenid`) REFERENCES `players` (`citizenid`) ON DELETE CASCADE ON UPDATE CASCADE | ||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; | ||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; |