Compare commits

...

2 Commits

Author SHA1 Message Date
4634c4ae98 Fix migration order
All checks were successful
Build and Push Docker Image / build (push) Successful in 2m9s
2026-03-18 01:24:06 +01:00
7afab94810 Delay of 20 seconds before migration 2026-03-18 01:21:54 +01:00
2 changed files with 24 additions and 20 deletions

View File

@@ -28,26 +28,6 @@ BEGIN
);
END;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Rental]') AND type = 'U')
BEGIN
CREATE TABLE Rental (
id BIGINT NOT NULL IDENTITY (1, 1),
rentalStart DATETIME NOT NULL,
rentalEnd DATETIME NOT NULL,
actualEnd DATETIME NULL,
customerID BIGINT NOT NULL,
vehicleID BIGINT NOT NULL,
PRIMARY KEY (id)
);
ALTER TABLE Rental
ADD CONSTRAINT FK_Customer_TO_Rental FOREIGN KEY (customerID) REFERENCES Customer (id);
ALTER TABLE Rental
ADD CONSTRAINT FK_Vehicle_TO_Rental FOREIGN KEY (vehicleID) REFERENCES Vehicle (id);
END;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[VehicleCategory]') AND type = 'U')
BEGIN
CREATE TABLE VehicleCategory (
@@ -78,4 +58,25 @@ BEGIN
ADD CONSTRAINT FK_VehicleCategory_TO_Vehicle FOREIGN KEY (vehicleCategoryID) REFERENCES VehicleCategory (id);
END;
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Rental]') AND type = 'U')
BEGIN
CREATE TABLE Rental (
id BIGINT NOT NULL IDENTITY (1, 1),
rentalStart DATETIME NOT NULL,
rentalEnd DATETIME NOT NULL,
actualEnd DATETIME NULL,
customerID BIGINT NOT NULL,
vehicleID BIGINT NOT NULL,
PRIMARY KEY (id)
);
ALTER TABLE Rental
ADD CONSTRAINT FK_Customer_TO_Rental FOREIGN KEY (customerID) REFERENCES Customer (id);
ALTER TABLE Rental
ADD CONSTRAINT FK_Vehicle_TO_Rental FOREIGN KEY (vehicleID) REFERENCES Vehicle (id);
END;

View File

@@ -1,6 +1,9 @@
#!/bin/bash
# Run the three SQL files using sqlcmd
# -S: Server, -U: User, -P: Password (passed via ENV)
sleep 20
echo "Applying SQL files..."
for migration in $(ls . | grep -E '\.sql$')