Skip to content

Commit

Permalink
Merge pull request #69 from AplinkosMinisterija/location-category-fix
Browse files Browse the repository at this point in the history
Location category fix
  • Loading branch information
DovMa authored Sep 26, 2024
2 parents 6c19bef + 2e447e4 commit cff6657
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 270 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = function (knex) {
return knex.schema.raw(`
DROP VIEW IF EXISTS recent_locations;
CREATE VIEW recent_locations AS
SELECT DISTINCT ON (location->>'cadastral_id', "created_by", "tenant_id")
location->>'name' AS name,
location->>'cadastral_id' AS cadastral_id,
location->>'municipality' AS municipality,
location->>'area' AS area,
location->>'length' AS length,
location->>'category' AS category,
"tenant_id",
"created_by" AS user_id,
"id" AS "fishStockingId",
"event_time"
FROM fish_stockings
ORDER BY location->>'cadastral_id', "user_id", "tenant_id", "event_time" DESC;
`);
};

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function (knex) {
return knex.schema.raw(`
DROP VIEW IF EXISTS recent_locations;
CREATE VIEW recent_locations AS
SELECT DISTINCT ON (location->>'cadastral_id', "created_by", "tenant_id")
location->>'name' AS name,
location->>'cadastral_id' AS cadastral_id,
location->>'municipality' AS municipality,
"tenant_id",
"created_by" AS user_id,
"id" AS "fishStockingId",
"event_time"
FROM fish_stockings
ORDER BY location->>'cadastral_id', "user_id", "tenant_id", "event_time" DESC;
`);
};
Loading

0 comments on commit cff6657

Please sign in to comment.