Skip to content

Commit

Permalink
Fix SQLFluff configuration and standardize procedure delimiters in cr…
Browse files Browse the repository at this point in the history
…eate_get_procedures.sql
  • Loading branch information
Vianpyro committed Nov 12, 2024
1 parent 5c83f3c commit ce0316e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 30 deletions.
1 change: 0 additions & 1 deletion .sqlfluff
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[sqlfluff]
dialect = mariadb
max_line_length = 100
exlude_rules = PRS
58 changes: 29 additions & 29 deletions create_get_procedures.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@ USE 0ce;

-- Player Procedures

DELIMITER //
DELIMITER ''

CREATE OR REPLACE PROCEDURE get_all_players()
BEGIN
SELECT player_id, player_name, email, gold, created_at, last_login FROM player;
END //
END ''

CREATE OR REPLACE PROCEDURE get_player_by_id(IN player_id INT)
BEGIN
SELECT player_id, player_name, email, gold, created_at, last_login
FROM player
WHERE id = player_id;
END //
END ''

CREATE OR REPLACE PROCEDURE get_player_by_name(IN player_name VARCHAR(100))
BEGIN
SELECT player_id, player_name, email, gold, created_at, last_login
FROM player
WHERE player_name = player_name;
END //
END ''

CREATE OR REPLACE PROCEDURE get_player_worlds(IN player_id INT)
BEGIN
SELECT w.world_id, w.world_name, w.world_description, w.created_at
FROM world w
JOIN player_world pw ON w.world_id = pw.world_id
WHERE pw.player_id = player_id;
END //
END ''

CREATE OR REPLACE PROCEDURE get_player_cities(IN player_id INT)
BEGIN
SELECT c.city_id, c.city_name, c.x, c.y, c.island_id
FROM city c
WHERE c.owner_id = player_id;
END //
END ''

-- World Procedures

Expand All @@ -46,111 +46,111 @@ BEGIN
SELECT world_id, world_name, world_description, seed, action_speed, unit_speed, trade_speed,
night_bonus, beginner_protection, morale, alliance_cap, world_status, created_at
FROM world;
END //
END ''

CREATE OR REPLACE PROCEDURE get_world_by_id(IN world_id INT)
BEGIN
SELECT world_id, world_name, world_description, seed, action_speed, unit_speed, trade_speed,
night_bonus, beginner_protection, morale, alliance_cap, world_status, created_at
FROM world
WHERE world_id = world_id;
END //
END ''

CREATE OR REPLACE PROCEDURE get_active_worlds()
BEGIN
SELECT world_id, world_name, world_description, created_at
FROM world
WHERE STATUS = 1;
END //
END ''

CREATE OR REPLACE PROCEDURE get_players_in_world(IN world_id INT)
BEGIN
SELECT p.player_id, p.player_name, p.email, p.gold, p.created_at
FROM player p
JOIN player_world pw ON p.player_id = pw.player_id
WHERE pw.world_id = world_id;
END //
END ''

CREATE OR REPLACE PROCEDURE get_world_islands(IN world_id INT)
BEGIN
SELECT island_id, x, y
FROM island
WHERE world_id = world_id;
END //
END ''

-- Island Procedures

CREATE OR REPLACE PROCEDURE get_all_islands()
BEGIN
SELECT island_id, x, y, world_id
FROM island;
END //
END ''

CREATE OR REPLACE PROCEDURE get_island_by_id(IN island_id INT)
BEGIN
SELECT island_id, x, y, world_id
FROM island
WHERE island_id = island_id;
END //
END ''

CREATE OR REPLACE PROCEDURE get_island_cities(IN island_id INT)
BEGIN
SELECT city_id, city_name, x, y, owner_id
FROM city
WHERE island_id = island_id;
END //
END ''

-- City Procedures

CREATE OR REPLACE PROCEDURE get_all_cities()
BEGIN
SELECT city_id, city_name, x, y, island_id, owner_id
FROM city;
END //
END ''

CREATE OR REPLACE PROCEDURE get_city_by_id(IN city_id INT)
BEGIN
SELECT city_id, city_name, x, y, island_id, owner_id
FROM city
WHERE id = city_id;
END //
END ''

CREATE OR REPLACE PROCEDURE get_cities_in_world(IN world_id INT)
BEGIN
SELECT c.city_id, c.city_name, c.x, c.y, c.owner_id, c.island_id
FROM city c
JOIN island i ON c.island_id = i.island_id
WHERE i.world_id = world_id;
END //
END ''

-- Building Procedures

CREATE OR REPLACE PROCEDURE get_all_buildings()
BEGIN
SELECT building_id, building_name, building_level, max_level, city_id
FROM building;
END //
END ''

CREATE OR REPLACE PROCEDURE get_city_buildings(IN city_id INT)
BEGIN
SELECT building_id, building_name, building_level, max_level
FROM building
WHERE city_id = city_id;
END //
END ''

CREATE OR REPLACE PROCEDURE get_building_by_id(IN building_id INT)
BEGIN
SELECT building_id, building_name, building_level, max_level, city_id
FROM building
WHERE id = building_id;
END //
END ''

CREATE OR REPLACE PROCEDURE get_building_prerequisites(IN building_id INT)
BEGIN
SELECT prerequisite_id
FROM building_prerequisite
WHERE building_id = building_id;
END //
END ''

-- Unit Procedures

Expand All @@ -160,15 +160,15 @@ BEGIN
population_cost, training_time, damage, defense_blunt, defense_distance, defense_sharp,
speed, can_fly
FROM unit;
END //
END ''

CREATE OR REPLACE PROCEDURE get_city_units(IN city_id INT)
BEGIN
SELECT u.unit_id, u.unit_name, cu.quantity
FROM unit u
JOIN city_unit cu ON u.unit_id = cu.unit_id
WHERE cu.city_id = city_id;
END //
END ''

CREATE OR REPLACE PROCEDURE get_unit_by_id(IN unit_id INT)
BEGIN
Expand All @@ -177,7 +177,7 @@ BEGIN
speed, can_fly
FROM unit
WHERE id = unit_id;
END //
END ''

-- Battle Procedures

Expand All @@ -186,30 +186,30 @@ BEGIN
SELECT battle_id, attacker_id, defender_id, battle_time, winner_id, loser_id, loot_wood,
loot_stone, loot_silver
FROM battle;
END //
END ''

CREATE OR REPLACE PROCEDURE get_battle_by_id(IN battle_id INT)
BEGIN
SELECT battle_id, attacker_id, defender_id, battle_time, winner_id, loser_id, loot_wood,
loot_stone, loot_silver
FROM battle
WHERE id = battle_id;
END //
END ''

CREATE OR REPLACE PROCEDURE get_player_battles(IN player_id INT)
BEGIN
SELECT battle_id, attacker_id, defender_id, battle_time, winner_id, loser_id, loot_wood,
loot_stone, loot_silver
FROM battle
WHERE attacker_id = player_id OR defender_id = player_id;
END //
END ''

CREATE OR REPLACE PROCEDURE get_battle_units(IN battle_id INT)
BEGIN
SELECT unit_id, quantity, side
FROM battle_unit
WHERE battle_id = battle_id;
END //
END ''

-- Miscellaneous Procedures

Expand All @@ -218,6 +218,6 @@ BEGIN
SELECT required_wood, required_stone, required_silver, required_population
FROM building_requirement
WHERE building_id = building_id;
END //
END ''

DELIMITER ;

0 comments on commit ce0316e

Please sign in to comment.