test: migration
This commit is contained in:
16
test/auto-common.ts
Normal file
16
test/auto-common.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { NocoApi, } from './../src/main.ts';
|
||||
import { useConfig } from '@kevisual/use-config'
|
||||
export const config = useConfig()
|
||||
import util from 'node:util';
|
||||
|
||||
export const nocoApi = new NocoApi({
|
||||
baseURL: config.NOCODB_URL || 'http://localhost:8080',
|
||||
token: config.NOCODB_API_KEY || '',
|
||||
});
|
||||
export const toNocoApi = new NocoApi({
|
||||
baseURL: config.TO_NOCODB_URL || 'http://localhost:8080',
|
||||
token: config.TO_NOCODB_API_KEY || '',
|
||||
});
|
||||
export const showMore = (obj: any) => {
|
||||
return util.inspect(obj, { depth: null, colors: true });
|
||||
}
|
||||
35
test/migration.ts
Normal file
35
test/migration.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { TableMigration, BaseMigration } from "../auto/migration ";
|
||||
|
||||
import { nocoApi, toNocoApi } from "./auto-common";
|
||||
|
||||
const toBaseId = 'pjc9ks10ttrv6vz';
|
||||
|
||||
const baseId = 'p0np8adsoc79odk';
|
||||
|
||||
const tableId = 'mgt91mysuwts4e6';
|
||||
|
||||
async function migrateTable() {
|
||||
const tableMigration = new TableMigration({
|
||||
fromTableId: tableId,
|
||||
fromNoco: nocoApi,
|
||||
toNoco: toNocoApi,
|
||||
toBaseId,
|
||||
});
|
||||
await tableMigration.migrate();
|
||||
}
|
||||
|
||||
// await migrateTable();
|
||||
|
||||
async function mirgtateBase() {
|
||||
const baseMigration = new BaseMigration({
|
||||
fromBaseId: baseId,
|
||||
toBaseId,
|
||||
fromNoco: nocoApi,
|
||||
toNoco: toNocoApi,
|
||||
});
|
||||
await baseMigration.migrate({
|
||||
excludeTables: ['控制中枢', '人生备忘录'],
|
||||
// includeTables: ['人生备忘录']
|
||||
});
|
||||
}
|
||||
mirgtateBase();
|
||||
Reference in New Issue
Block a user