feat: implement battle replay module with database migrations, repository, and CRUD service endpoints
All checks were successful
Build and Release / release (push) Successful in 1m32s
All checks were successful
Build and Release / release (push) Successful in 1m32s
This commit is contained in:
1
db/migrations/000017_battle_replays.down.sql
Normal file
1
db/migrations/000017_battle_replays.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS battle_replays;
|
||||
28
db/migrations/000017_battle_replays.up.sql
Normal file
28
db/migrations/000017_battle_replays.up.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
CREATE TABLE IF NOT EXISTS battle_replays (
|
||||
id UUID PRIMARY KEY DEFAULT uuidv7(),
|
||||
geometry_id UUID NOT NULL REFERENCES geometries(id) ON DELETE CASCADE,
|
||||
project_id UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
||||
target_geometry_ids JSONB NOT NULL DEFAULT '[]'::jsonb,
|
||||
detail JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
is_deleted BOOLEAN NOT NULL DEFAULT false,
|
||||
created_at TIMESTAMPTZ DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ DEFAULT now()
|
||||
);
|
||||
|
||||
CREATE INDEX idx_battle_replays_geometry_id ON battle_replays(geometry_id)
|
||||
WHERE is_deleted = false;
|
||||
|
||||
CREATE INDEX idx_battle_replays_project_id ON battle_replays(project_id)
|
||||
WHERE is_deleted = false;
|
||||
|
||||
CREATE INDEX idx_battle_replays_target_geometry_ids ON battle_replays USING GIN (target_geometry_ids)
|
||||
WHERE is_deleted = false;
|
||||
|
||||
CREATE INDEX idx_battle_replays_updated_at ON battle_replays(updated_at DESC)
|
||||
WHERE is_deleted = false;
|
||||
|
||||
DROP TRIGGER IF EXISTS trigger_battle_replays_updated_at ON battle_replays;
|
||||
CREATE TRIGGER trigger_battle_replays_updated_at
|
||||
BEFORE UPDATE ON battle_replays
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION update_updated_at();
|
||||
Reference in New Issue
Block a user