mirror of
https://github.com/hotomoe/hotomoe
synced 2024-12-15 07:08:23 +09:00
16 lines
922 B
JavaScript
16 lines
922 B
JavaScript
|
export class BirthdayIndex1711478468155 {
|
||
|
name = 'BirthdayIndex1711478468155'
|
||
|
|
||
|
async up(queryRunner) {
|
||
|
await queryRunner.query(`DROP INDEX "public"."IDX_de22cd2b445eee31ae51cdbe99"`);
|
||
|
await queryRunner.query(`CREATE OR REPLACE FUNCTION get_birthday_date(birthday TEXT) RETURNS SMALLINT AS $$ BEGIN RETURN CAST((SUBSTR(birthday, 6, 2) || SUBSTR(birthday, 9, 2)) AS SMALLINT); END; $$ LANGUAGE plpgsql IMMUTABLE;`);
|
||
|
await queryRunner.query(`CREATE INDEX "IDX_USERPROFILE_BIRTHDAY_DATE" ON "user_profile" (get_birthday_date("birthday"))`);
|
||
|
}
|
||
|
|
||
|
async down(queryRunner) {
|
||
|
await queryRunner.query(`CREATE INDEX "IDX_de22cd2b445eee31ae51cdbe99" ON "user_profile" (substr("birthday", 6, 5))`);
|
||
|
await queryRunner.query(`DROP INDEX "public"."IDX_USERPROFILE_BIRTHDAY_DATE"`);
|
||
|
await queryRunner.query(`DROP FUNCTION IF EXISTS get_birthday_date(birthday TEXT)`);
|
||
|
}
|
||
|
}
|