diff --git a/PostgressDB/Dockerfile b/PostgressDB/Dockerfile new file mode 100644 index 0000000..09b6d7b --- /dev/null +++ b/PostgressDB/Dockerfile @@ -0,0 +1,13 @@ +# Use the official PostgreSQL image as the base image +FROM postgres:latest + +# Set environment variables for PostgreSQL +ENV POSTGRES_DB=mydatabase +ENV POSTGRES_USER=myuser +ENV POSTGRES_PASSWORD=mypassword + +# Copy initialization scripts into the Docker image +COPY init.sql /docker-entrypoint-initdb.d/ + +# Expose the PostgreSQL port +EXPOSE 5432 diff --git a/PostgressDB/docker-compose.yml b/PostgressDB/docker-compose.yml new file mode 100644 index 0000000..2d00b6e --- /dev/null +++ b/PostgressDB/docker-compose.yml @@ -0,0 +1,12 @@ +services: + db: + build: . --no-cache + container_name: Beyond_Heroes_War_DB + ports: + - "6732:5432" + environment: + POSTGRES_DB: BHDB + POSTGRES_USER: APIUser + POSTGRES_PASSWORD: mypassword + volumes: + - ./init.sql:/docker-entrypoint-initdb.d/init.sql \ No newline at end of file diff --git a/PostgressDB/init.sql b/PostgressDB/init.sql new file mode 100644 index 0000000..0931c26 --- /dev/null +++ b/PostgressDB/init.sql @@ -0,0 +1,55 @@ +-- Create the AssaultTroop table +CREATE TABLE AssaultTroop ( + Id SERIAL PRIMARY KEY, + ATId INT, + Name VARCHAR(255) NOT NULL, + Faction INT NOT NULL, -- 0 - Neutral, 1 - Allies, 2 - Axis + Type INT NOT NULL, -- 1 - Infantry, 4 - Armor + Province INT NOT NULL, -- -1 - Not deployed, Province IDs + Orders JSONB NOT NULL, -- JSON String + Owner INT NOT NULL -- Owner ID +); + +INSERT INTO AssaultTroop (Id, Name, Faction, Type, Province, Orders, Owner) VALUES + (1, 'First Infantry Division', 2, 1, 0, '{"Dep": [], "Mov": []}', 1), + (2, 'First Infantry Division', 1, 1, 0, '{"Dep": [], "Mov": []}', 2), + (3, 'Second Infantry Division', 1, 1, 0, '{"Dep": [], "Mov": []}', 2), + (4, 'Third Infantry Division', 1, 1, 0, '{"Dep": [], "Mov": []}', 2), + (5, 'Cheeki Breeki Boys', 2, 1, 0, '{"Dep": [], "Mov": []}', 3), + (6, 'Hitlers Men', 2, 1, 1, '{"Dep": [], "Mov": []}', 4), + (7, 'Hitlers Men', 2, 1, 1, '{"Dep": [], "Mov": []}', 4), + (8, 'Hitlers Men', 2, 1, 1, '{"Dep": [], "Mov": []}', 4), + (9, 'Cheeki Breeki Boys', 2, 1, 1, '{"Dep": [], "Mov": []}', 3), + (10, 'Hitlers Men', 2, 1, 0, '{"Dep": [], "Mov": []}', 4), + (11, 'Fifth Infantry Division', 1, 1, -1, '{"Dep": [], "Mov": []}', 5), + (12, 'Fifth Infantry Division', 1, 1, -1, '{"Dep": [], "Mov": []}', 5), + (13, 'First Armor Division', 1, 4, 2, '{"Dep": [], "Mov": []}', 2), + (14, 'Second Armor Division', 1, 4, 2, '{"Dep": [], "Mov": []}', 2), + (15, 'Cheeki Breeki Tonks', 2, 4, 2, '{"Dep": [], "Mov": []}', 3); + + +-- Create the Province table +CREATE TABLE Province ( + Id SERIAL PRIMARY KEY, + ProvinceId INT, + Name VARCHAR(255) NOT NULL, + Faction INT NOT NULL, -- 0 - Neutral, 1 - Allies, 2 - Axis + Multiplier DECIMAL(3, 2) NOT NULL, -- 0-1 + ATs JSONB NOT NULL, -- JSON String + State INT NOT NULL -- 0 - Peace, 1 - War +); + +INSERT INTO Province (Id, Name, Faction, Multiplier, ATs, State) VALUES + (0, 'Hessen', 2, 1.00, '{"Allies": [2, 3, 4], "Axis": [1, 5, 9, 10]}', 1), + (1, 'Thuringen', 2, 1.00, '{"Allies": [], "Axis": [6, 7, 8]}', 0), + (2, 'Rheinland-Pfalz', 1, 1.00, '{"Allies": [13, 14], "Axis": [15]}', 1), + (4, 'Baden-Wurttemberg', 1, 1.00, '{"Allies": [17, 19], "Axis": []}', 0), + (3, 'Saarland', 1, 1.00, '{"Allies": [16, 17, 18], "Axis": []}', 0), + (5, 'Bayern', 1, 1.00, '{"Allies": [20, 21], "Axis": []}', 0), + (6, 'Sachsen', 1, 1.00, '{"Allies": [23], "Axis": []}', 0), + (7, 'Brandenburg', 2, 1.00, '{"Allies": [], "Axis": [25, 26, 27, 28]}', 0), + (8, 'Berlin', 2, 1.00, '{"Allies": [], "Axis": [29, 30, 31]}', 0), + (9, 'Schleswig-Holstein', 2, 1.00, '{"Allies": [], "Axis": [33]}', 0), + (10, 'Hamburg', 2, 1.00, '{"Allies": [], "Axis": [34]}', 0), + (11, 'Niedersachsen', 2, 1.00, '{"Allies": [], "Axis": [35]}', 0), + (12, 'Nordreihn-Westfalen', 1, 1.00, '{"Allies": [36, 37], "Axis": []}', 0);