-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
store searchable_by in searches made and clean search_made__appellati…
…ons when no appellation is provided
- Loading branch information
Showing
4 changed files
with
27 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
back/src/config/pg/migrations/1726826257133_add-searchable-by-column-in-searches-made.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { MigrationBuilder } from "node-pg-migrate"; | ||
|
||
export async function up(pgm: MigrationBuilder): Promise<void> { | ||
pgm.createType("searchable_by", ["students", "jobSeekers"]); | ||
pgm.addColumn("searches_made", { | ||
searchable_by: { type: "searchable_by" }, | ||
}); | ||
|
||
await pgm.db.query(` | ||
DELETE FROM searches_made__appellation_code where appellation_code is null; | ||
`); | ||
pgm.alterColumn("searches_made__appellation_code", "appellation_code", { | ||
notNull: true, | ||
}); | ||
} | ||
|
||
export async function down(pgm: MigrationBuilder): Promise<void> { | ||
pgm.dropColumn("searches_made", "searchable_by"); | ||
pgm.dropType("searchable_by"); | ||
pgm.alterColumn("searches_made__appellation_code", "appellation_code", { | ||
notNull: false, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters