0.2.0 cleaning script (#2342)
* Display maxUpdatedAt for each workspace Schema * Factorize functions * Add max update for public workspaces * Merge everything in a single json * Enrich results * Get from proper table * Update * Move to proper command file * Add a dry-run option * Remove workspaces from database * Fix DeleteWorkspace method * Add new option * Remove proper data when deleting workspace * Minor improvements
This commit is contained in:
@ -1,28 +1,6 @@
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
|
||||
import console from 'console';
|
||||
|
||||
import { config } from 'dotenv';
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
config();
|
||||
|
||||
const configService = new ConfigService();
|
||||
|
||||
export const connectionSource = new DataSource({
|
||||
type: 'postgres',
|
||||
logging: false,
|
||||
url: configService.get<string>('PG_DATABASE_URL'),
|
||||
});
|
||||
|
||||
const performQuery = async (query: string, consoleDescription: string) => {
|
||||
try {
|
||||
await connectionSource.query(query);
|
||||
console.log(`Performed '${consoleDescription}' successfully`);
|
||||
} catch (err) {
|
||||
console.error(`Failed to perform '${consoleDescription}':`, err);
|
||||
}
|
||||
};
|
||||
import { connectionSource, performQuery } from './utils';
|
||||
|
||||
connectionSource
|
||||
.initialize()
|
||||
|
||||
@ -1,28 +1,6 @@
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
|
||||
import console from 'console';
|
||||
|
||||
import { config } from 'dotenv';
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
config();
|
||||
|
||||
const configService = new ConfigService();
|
||||
|
||||
export const connectionSource = new DataSource({
|
||||
type: 'postgres',
|
||||
logging: false,
|
||||
url: configService.get<string>('PG_DATABASE_URL'),
|
||||
});
|
||||
|
||||
const performQuery = async (query: string, consoleDescription: string) => {
|
||||
try {
|
||||
await connectionSource.query(query);
|
||||
console.log(`Performed '${consoleDescription}' successfully`);
|
||||
} catch (err) {
|
||||
console.error(`Failed to perform '${consoleDescription}':`, err);
|
||||
}
|
||||
};
|
||||
import { connectionSource, performQuery } from './utils';
|
||||
|
||||
connectionSource
|
||||
.initialize()
|
||||
|
||||
28
server/scripts/utils.ts
Normal file
28
server/scripts/utils.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
|
||||
import console from 'console';
|
||||
|
||||
import { config } from 'dotenv';
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
config();
|
||||
const configService = new ConfigService();
|
||||
export const connectionSource = new DataSource({
|
||||
type: 'postgres',
|
||||
logging: false,
|
||||
url: configService.get<string>('PG_DATABASE_URL'),
|
||||
});
|
||||
|
||||
export const performQuery = async (
|
||||
query: string,
|
||||
consoleDescription: string,
|
||||
withLog = true,
|
||||
) => {
|
||||
try {
|
||||
const result = await connectionSource.query(query);
|
||||
withLog && console.log(`Performed '${consoleDescription}' successfully`);
|
||||
return result;
|
||||
} catch (err) {
|
||||
withLog && console.error(`Failed to perform '${consoleDescription}':`, err);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user