feat: initial commit
This commit is contained in:
21
migrations/1775776542850-adds-base-triggers.ts
Normal file
21
migrations/1775776542850-adds-base-triggers.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddsBaseTriggers1775776542850 implements MigrationInterface {
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
CREATE OR REPLACE FUNCTION set_updated_at()
|
||||
RETURNS TRIGGER AS $$
|
||||
BEGIN
|
||||
NEW.updated_at = now();
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
--end-sql`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`--sql
|
||||
DROP FUNCTION set_updated_at();
|
||||
--end-sql`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user