feat: Update NPS Value Survey (#9638)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in> Co-authored-by: Tomi Turtiainen <10324676+tomi@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@db/types';
|
||||
|
||||
export class AddActivatedAtUserSetting1717498465931 implements ReversibleMigration {
|
||||
async up({ queryRunner, escape }: MigrationContext) {
|
||||
const now = Date.now();
|
||||
await queryRunner.query(
|
||||
`UPDATE ${escape.tableName('user')}
|
||||
SET settings = JSON_SET(COALESCE(settings, '{}'), '$.userActivatedAt', CAST('${now}' AS JSON))
|
||||
WHERE settings IS NOT NULL AND JSON_EXTRACT(settings, '$.userActivated') = true`,
|
||||
);
|
||||
}
|
||||
|
||||
async down({ queryRunner, escape }: MigrationContext) {
|
||||
await queryRunner.query(
|
||||
`UPDATE ${escape.tableName('user')}
|
||||
SET settings = JSON_REMOVE(CAST(settings AS JSON), '$.userActivatedAt')
|
||||
WHERE settings IS NOT NULL`,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,7 @@ import { RemoveFailedExecutionStatus1711018413374 } from '../common/171101841337
|
||||
import { MoveSshKeysToDatabase1711390882123 } from '../common/1711390882123-MoveSshKeysToDatabase';
|
||||
import { RemoveNodesAccess1712044305787 } from '../common/1712044305787-RemoveNodesAccess';
|
||||
import { MakeExecutionStatusNonNullable1714133768521 } from '../common/1714133768521-MakeExecutionStatusNonNullable';
|
||||
import { AddActivatedAtUserSetting1717498465931 } from './1717498465931-AddActivatedAtUserSetting';
|
||||
|
||||
export const mysqlMigrations: Migration[] = [
|
||||
InitialMigration1588157391238,
|
||||
@@ -117,4 +118,5 @@ export const mysqlMigrations: Migration[] = [
|
||||
RemoveNodesAccess1712044305787,
|
||||
CreateProject1714133768519,
|
||||
MakeExecutionStatusNonNullable1714133768521,
|
||||
AddActivatedAtUserSetting1717498465931,
|
||||
];
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@db/types';
|
||||
|
||||
export class AddActivatedAtUserSetting1717498465931 implements ReversibleMigration {
|
||||
async up({ queryRunner, escape }: MigrationContext) {
|
||||
const now = Date.now();
|
||||
await queryRunner.query(
|
||||
`UPDATE ${escape.tableName('user')}
|
||||
SET settings = jsonb_set(COALESCE(settings::jsonb, '{}'), '{userActivatedAt}', to_jsonb(${now}))
|
||||
WHERE settings IS NOT NULL AND (settings->>'userActivated')::boolean = true`,
|
||||
);
|
||||
}
|
||||
|
||||
async down({ queryRunner, escape }: MigrationContext) {
|
||||
await queryRunner.query(
|
||||
`UPDATE ${escape.tableName('user')} SET settings = settings::jsonb - 'userActivatedAt' WHERE settings IS NOT NULL`,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,7 @@ import { RemoveFailedExecutionStatus1711018413374 } from '../common/171101841337
|
||||
import { MoveSshKeysToDatabase1711390882123 } from '../common/1711390882123-MoveSshKeysToDatabase';
|
||||
import { RemoveNodesAccess1712044305787 } from '../common/1712044305787-RemoveNodesAccess';
|
||||
import { MakeExecutionStatusNonNullable1714133768521 } from '../common/1714133768521-MakeExecutionStatusNonNullable';
|
||||
import { AddActivatedAtUserSetting1717498465931 } from './1717498465931-AddActivatedAtUserSetting';
|
||||
|
||||
export const postgresMigrations: Migration[] = [
|
||||
InitialMigration1587669153312,
|
||||
@@ -115,4 +116,5 @@ export const postgresMigrations: Migration[] = [
|
||||
RemoveNodesAccess1712044305787,
|
||||
CreateProject1714133768519,
|
||||
MakeExecutionStatusNonNullable1714133768521,
|
||||
AddActivatedAtUserSetting1717498465931,
|
||||
];
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||||
|
||||
export class AddActivatedAtUserSetting1717498465931 implements ReversibleMigration {
|
||||
transaction = false as const;
|
||||
|
||||
async up({ queryRunner, escape }: MigrationContext) {
|
||||
const now = Date.now();
|
||||
await queryRunner.query(
|
||||
`UPDATE ${escape.tableName('user')}
|
||||
SET settings = JSON_SET(settings, '$.userActivatedAt', ${now})
|
||||
WHERE JSON_EXTRACT(settings, '$.userActivated') = true;`,
|
||||
);
|
||||
}
|
||||
|
||||
async down({ queryRunner, escape }: MigrationContext) {
|
||||
await queryRunner.query(
|
||||
`UPDATE ${escape.tableName('user')} SET settings = JSON_REMOVE(settings, '$.userActivatedAt')`,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,7 @@ import { RemoveFailedExecutionStatus1711018413374 } from '../common/171101841337
|
||||
import { MoveSshKeysToDatabase1711390882123 } from '../common/1711390882123-MoveSshKeysToDatabase';
|
||||
import { RemoveNodesAccess1712044305787 } from '../common/1712044305787-RemoveNodesAccess';
|
||||
import { MakeExecutionStatusNonNullable1714133768521 } from '../common/1714133768521-MakeExecutionStatusNonNullable';
|
||||
import { AddActivatedAtUserSetting1717498465931 } from './1717498465931-AddActivatedAtUserSetting';
|
||||
|
||||
const sqliteMigrations: Migration[] = [
|
||||
InitialMigration1588102412422,
|
||||
@@ -111,6 +112,7 @@ const sqliteMigrations: Migration[] = [
|
||||
RemoveNodesAccess1712044305787,
|
||||
CreateProject1714133768519,
|
||||
MakeExecutionStatusNonNullable1714133768521,
|
||||
AddActivatedAtUserSetting1717498465931,
|
||||
];
|
||||
|
||||
export { sqliteMigrations };
|
||||
|
||||
Reference in New Issue
Block a user