Skip to content

Commit bbceec8

Browse files
New DB structure with prop table. (#88)
* Migrations and schema for new structure * models.rs, prop id fk not nullable * added name back to defender_type, mine_type models, schema and responses, defense util.rs, validate.rs, shortest_path.rs for new structure. * get map details for attack mapspace block id for mine type * attack util * inventory util.rs * add_500_artifacts_to_users.rs for new structure * dummy data * delete old dummy_data and schema * unused imports removed * removed empty newlines in schema.rs * fmt * fix: dummy update --------- Co-authored-by: thatchinkumar2005 <[email protected]>
1 parent 3d7ba11 commit bbceec8

File tree

13 files changed

+498
-278
lines changed

13 files changed

+498
-278
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN apt-get update -y && apt-get install -y \
66
pkg-config \
77
libssl-dev
88
RUN cargo install diesel_cli --no-default-features --features postgres
9-
RUN cargo install cargo-watch
9+
RUN cargo install cargo-watch --locked
1010
RUN cargo install cargo-chef
1111

1212
FROM base AS planner

dummy_data.sql

Lines changed: 144 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ DELETE FROM public.game;
2424
DELETE FROM public.map_layout;
2525
DELETE FROM public.user;
2626
DELETE FROM public.levels_fixture;
27+
DELETE FROM public.prop;
2728

2829
COPY public.levels_fixture FROM stdin;
29-
1 2024_01_01 00:00:00 2025_01_01 00:00:00 40 1 3
30+
1 2025_01_01 00:00:00 2026_01_01 00:00:00 40 1 3
3031
\.
3132

3233
COPY public.user FROM stdin;
@@ -37,65 +38,82 @@ COPY public.map_layout FROM stdin;
3738
1 1 1 t
3839
\.
3940

41+
COPY public.prop FROM stdin;
42+
0 0 0
43+
1 8 0
44+
2 10 0
45+
3 6 0
46+
4 7 0
47+
5 8 0
48+
6 9 0
49+
7 9 0
50+
8 10 0
51+
9 8 0
52+
10 5 0
53+
11 6 0
54+
12 7 0
55+
\.
56+
57+
4058
COPY public.building_type FROM stdin;
41-
0 Road 1 1 0 0 0 0
42-
1 Bank 3 3 2147483647 1 10 120
43-
2 Building_2 4 4 120 1 10 140
44-
3 Building_3 5 5 140 1 10 160
45-
4 Building_4 3 3 90 1 10 110
46-
5 Building_5 4 4 110 1 10 130
47-
6 Building_6 5 5 130 1 10 150
48-
7 Building_7 3 3 80 1 10 100
49-
8 Building_8 4 4 100 1 10 120
50-
9 Building_9 5 5 120 1 10 140
51-
10 Building_10 3 3 70 1 10 90
52-
11 Building_11 4 4 90 1 10 110
53-
12 Building_12 5 5 110 1 10 130
54-
13 Building_13 3 3 60 1 10 80
55-
14 Building_14 4 4 80 1 10 100
56-
15 Building_15 5 5 100 1 10 120
57-
16 Bank 3 3 2147483647 2 50 140
58-
17 Building_2 4 4 130 2 75 160
59-
18 Building_3 5 5 150 2 100 180
60-
19 Building_4 3 3 100 2 25 120
61-
20 Building_5 4 4 120 2 50 140
62-
21 Building_6 5 5 140 2 75 160
63-
22 Building_7 3 3 90 2 20 110
64-
23 Building_8 4 4 110 2 45 130
65-
24 Building_9 5 5 130 2 70 150
66-
25 Building_10 3 3 80 2 15 100
67-
26 Building_11 4 4 100 2 40 120
68-
27 Building_12 5 5 120 2 65 140
69-
28 Building_13 3 3 70 2 10 90
70-
29 Building_14 4 4 90 2 35 110
71-
30 Building_15 5 5 110 2 60 130
72-
31 Bank 3 3 2147483647 3 -1 160
73-
32 Building_2 4 4 140 3 -1 180
74-
33 Building_3 5 5 160 3 -1 200
75-
34 Building_4 3 3 110 3 -1 140
76-
35 Building_5 4 4 130 3 -1 160
77-
36 Building_6 5 5 150 3 -1 180
78-
37 Building_7 3 3 100 3 -1 120
79-
38 Building_8 4 4 120 3 -1 140
80-
39 Building_9 5 5 140 3 -1 160
81-
40 Building_10 3 3 90 3 -1 110
82-
41 Building_11 4 4 110 3 -1 130
83-
42 Building_12 5 5 130 3 -1 150
84-
43 Building_13 3 3 80 3 -1 100
85-
44 Building_14 4 4 100 3 -1 120
86-
45 Building_15 5 5 120 3 -1 140
59+
0 Road 1 1 0 0 0 0 0
60+
1 Bank 3 3 2147483647 1 10 120 0
61+
2 Building_2 4 4 120 1 10 140 0
62+
3 Building_3 5 5 140 1 10 160 0
63+
4 Building_4 3 3 90 1 10 110 0
64+
5 Building_5 4 4 110 1 10 130 0
65+
6 Building_6 5 5 130 1 10 150 0
66+
7 Building_7 3 3 80 1 10 100 0
67+
8 Building_8 4 4 100 1 10 120 0
68+
9 Building_9 5 5 120 1 10 140 0
69+
10 Building_10 3 3 70 1 10 90 0
70+
11 Building_11 4 4 90 1 10 110 0
71+
12 Building_12 5 5 110 1 10 130 0
72+
13 Building_13 3 3 60 1 10 80 0
73+
14 Building_14 4 4 80 1 10 100 0
74+
15 Building_15 5 5 100 1 10 120 0
75+
16 Bank 3 3 2147483647 2 50 140 0
76+
17 Building_2 4 4 130 2 75 160 0
77+
18 Building_3 5 5 150 2 100 180 0
78+
19 Building_4 3 3 100 2 25 120 0
79+
20 Building_5 4 4 120 2 50 140 0
80+
21 Building_6 5 5 140 2 75 160 0
81+
22 Building_7 3 3 90 2 20 110 0
82+
23 Building_8 4 4 110 2 45 130 0
83+
24 Building_9 5 5 130 2 70 150 0
84+
25 Building_10 3 3 80 2 15 100 0
85+
26 Building_11 4 4 100 2 40 120 0
86+
27 Building_12 5 5 120 2 65 140 0
87+
28 Building_13 3 3 70 2 10 90 0
88+
29 Building_14 4 4 90 2 35 110 0
89+
30 Building_15 5 5 110 2 60 130 0
90+
31 Bank 3 3 2147483647 3 -1 160 0
91+
32 Building_2 4 4 140 3 -1 180 0
92+
33 Building_3 5 5 160 3 -1 200 0
93+
34 Building_4 3 3 110 3 -1 140 0
94+
35 Building_5 4 4 130 3 -1 160 0
95+
36 Building_6 5 5 150 3 -1 180 0
96+
37 Building_7 3 3 100 3 -1 120 0
97+
38 Building_8 4 4 120 3 -1 140 0
98+
39 Building_9 5 5 140 3 -1 160 0
99+
40 Building_10 3 3 90 3 -1 110 0
100+
41 Building_11 4 4 110 3 -1 130 0
101+
42 Building_12 5 5 130 3 -1 150 0
102+
43 Building_13 3 3 80 3 -1 100 0
103+
44 Building_14 4 4 100 3 -1 120 0
104+
45 Building_15 5 5 120 3 -1 140 0
87105
\.
88106

89107
COPY public.defender_type FROM stdin;
90-
1 4 50 8 1 10 Defender_1
91-
2 4 40 10 1 10 Defender_2
92-
3 4 30 6 1 10 Defender_3
93-
4 4 60 7 2 150 Defender_1
94-
5 4 50 8 2 250 Defender_2
95-
6 4 40 9 2 350 Defender_3
96-
7 4 70 9 3 -1 Defender_1
97-
8 4 60 10 3 -1 Defender_2
98-
9 4 50 8 3 -1 Defender_3
108+
1 4 50 1 10 Defender_1 1
109+
2 4 40 1 10 Defender_2 2
110+
3 4 30 1 10 Defender_3 3
111+
4 4 60 2 150 Defender_1 4
112+
5 4 50 2 250 Defender_2 5
113+
6 4 40 2 350 Defender_3 6
114+
7 4 70 3 -1 Defender_1 7
115+
8 4 60 3 -1 Defender_2 8
116+
9 4 50 3 -1 Defender_3 9
99117
\.
100118

101119
COPY public.emp_type FROM stdin;
@@ -111,82 +129,82 @@ COPY public.emp_type FROM stdin;
111129
\.
112130

113131
COPY public.mine_type FROM stdin;
114-
1 5 50 1 10 Mine_1
115-
2 6 70 2 120 Mine_1
116-
3 7 90 3 -1 Mine_1
132+
1 50 1 10 Mine_1 10
133+
2 70 2 120 Mine_1 11
134+
3 90 3 -1 Mine_1 12
117135
\.
118136

119137
COPY public.attacker_type FROM stdin;
120-
1 100 4 10 1 10 Attacker_1
121-
2 120 4 12 1 10 Attacker_2
122-
3 80 4 8 1 10 Attacker_3
123-
4 150 4 15 2 80 Attacker_1
124-
5 180 4 18 2 100 Attacker_2
125-
6 120 4 12 2 60 Attacker_3
126-
7 200 4 20 3 -1 Attacker_1
127-
8 240 4 24 3 -1 Attacker_2
128-
9 160 4 16 3 -1 Attacker_3
138+
1 100 4 10 1 10 Attacker_1 0
139+
2 120 4 12 1 10 Attacker_2 0
140+
3 80 4 8 1 10 Attacker_3 0
141+
4 150 4 15 2 80 Attacker_1 0
142+
5 180 4 18 2 100 Attacker_2 0
143+
6 120 4 12 2 60 Attacker_3 0
144+
7 200 4 20 3 -1 Attacker_1 0
145+
8 240 4 24 3 -1 Attacker_2 0
146+
9 160 4 16 3 -1 Attacker_3 0
129147
\.
130148

131149
COPY public.block_type FROM stdin;
132-
0 \N \N building 0
133-
1 \N \N building 1
134-
2 \N \N building 2
135-
3 \N \N building 3
136-
4 \N \N building 4
137-
5 \N \N building 5
138-
6 \N \N building 6
139-
7 \N \N building 7
140-
8 \N \N building 8
141-
9 \N \N building 9
142-
10 \N \N building 10
143-
11 \N \N building 11
144-
12 \N \N building 12
145-
13 \N \N building 13
146-
14 \N \N building 14
147-
15 \N \N building 15
148-
16 \N \N building 16
149-
17 \N \N building 17
150-
18 \N \N building 18
151-
19 \N \N building 19
152-
20 \N \N building 20
153-
21 \N \N building 21
154-
22 \N \N building 22
155-
23 \N \N building 23
156-
24 \N \N building 24
157-
25 \N \N building 25
158-
26 \N \N building 26
159-
27 \N \N building 27
160-
28 \N \N building 28
161-
29 \N \N building 29
162-
30 \N \N building 30
163-
31 \N \N building 31
164-
32 \N \N building 32
165-
33 \N \N building 33
166-
34 \N \N building 34
167-
35 \N \N building 35
168-
36 \N \N building 36
169-
37 \N \N building 37
170-
38 \N \N building 38
171-
39 \N \N building 39
172-
40 \N \N building 40
173-
41 \N \N building 41
174-
42 \N \N building 42
175-
43 \N \N building 43
176-
44 \N \N building 44
177-
45 \N \N building 45
178-
46 1 \N defender 0
179-
47 2 \N defender 0
180-
48 3 \N defender 0
181-
49 4 \N defender 0
182-
50 5 \N defender 0
183-
51 6 \N defender 0
184-
52 7 \N defender 0
185-
53 8 \N defender 0
186-
54 9 \N defender 0
187-
55 \N 1 mine 0
188-
56 \N 2 mine 0
189-
57 \N 3 mine 0
150+
0 building 0
151+
1 building 1
152+
2 building 2
153+
3 building 3
154+
4 building 4
155+
5 building 5
156+
6 building 6
157+
7 building 7
158+
8 building 8
159+
9 building 9
160+
10 building 10
161+
11 building 11
162+
12 building 12
163+
13 building 13
164+
14 building 14
165+
15 building 15
166+
16 building 16
167+
17 building 17
168+
18 building 18
169+
19 building 19
170+
20 building 20
171+
21 building 21
172+
22 building 22
173+
23 building 23
174+
24 building 24
175+
25 building 25
176+
26 building 26
177+
27 building 27
178+
28 building 28
179+
29 building 29
180+
30 building 30
181+
31 building 31
182+
32 building 32
183+
33 building 33
184+
34 building 34
185+
35 building 35
186+
36 building 36
187+
37 building 37
188+
38 building 38
189+
39 building 39
190+
40 building 40
191+
41 building 41
192+
42 building 42
193+
43 building 43
194+
44 building 44
195+
45 building 45
196+
46 defender 1
197+
47 defender 2
198+
48 defender 3
199+
49 defender 4
200+
50 defender 5
201+
51 defender 6
202+
52 defender 7
203+
53 defender 8
204+
54 defender 9
205+
55 mine 1
206+
56 mine 2
207+
57 mine 3
190208
\.
191209

192210
COPY public.available_blocks FROM stdin;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
-- Remove foreign key constraints for prop_id
2+
ALTER TABLE building_type
3+
DROP CONSTRAINT IF EXISTS fk_building_prop;
4+
5+
ALTER TABLE defender_type
6+
DROP CONSTRAINT IF EXISTS fk_defender_prop;
7+
8+
ALTER TABLE mine_type
9+
DROP CONSTRAINT IF EXISTS fk_mine_prop;
10+
11+
ALTER TABLE attacker_type
12+
DROP CONSTRAINT IF EXISTS fk_attacker_prop;
13+
14+
-- Remove prop_id column from defender_type, mine_type, building_type, and attacker_type
15+
ALTER TABLE building_type
16+
DROP COLUMN IF EXISTS prop_id;
17+
18+
ALTER TABLE defender_type
19+
DROP COLUMN IF EXISTS prop_id;
20+
21+
ALTER TABLE mine_type
22+
DROP COLUMN IF EXISTS prop_id;
23+
24+
ALTER TABLE attacker_type
25+
DROP COLUMN IF EXISTS prop_id;
26+
27+
-- Restore "name" and radius columns in defender_type, mine_type, and attacker_type
28+
ALTER TABLE defender_type
29+
ADD COLUMN "name" TEXT NOT NULL,
30+
ADD COLUMN radius INTEGER NOT NULL;
31+
32+
ALTER TABLE mine_type
33+
ADD COLUMN "name" TEXT NOT NULL,
34+
ADD COLUMN radius INTEGER NOT NULL;
35+
36+
ALTER TABLE attacker_type
37+
ADD COLUMN "name" TEXT NOT NULL,
38+
ADD COLUMN radius INTEGER NOT NULL;
39+
40+
-- Restore defender_type, mine_type, and building_type columns in block_type
41+
ALTER TABLE block_type
42+
DROP COLUMN IF EXISTS category_id,
43+
ADD COLUMN defender_type TEXT,
44+
ADD COLUMN mine_type TEXT,
45+
ADD COLUMN building_type TEXT;
46+
47+
-- Drop the prop table
48+
DROP TABLE IF EXISTS prop;

0 commit comments

Comments
 (0)