mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-22 05:16:00 +00:00
This commit is contained in:
@@ -3,7 +3,7 @@ const driverConnect = require('../utility/driverConnect');
|
|||||||
const engines = require('@dbgate/engines');
|
const engines = require('@dbgate/engines');
|
||||||
|
|
||||||
async function tableWriter({ connection, schemaName, pureName, ...options }) {
|
async function tableWriter({ connection, schemaName, pureName, ...options }) {
|
||||||
console.log(`write table ${schemaName}.${pureName}`);
|
console.log(`Write table ${schemaName}.${pureName}`);
|
||||||
|
|
||||||
const driver = engines(connection);
|
const driver = engines(connection);
|
||||||
const pool = await driverConnect(driver, connection);
|
const pool = await driverConnect(driver, connection);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
const { prepareTableForImport } = require('@dbgate/tools');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,7 +35,7 @@ function createBulkInsertStream(driver, mssql, stream, pool, name, options) {
|
|||||||
if (options.createIfNotExists && (!structure || options.dropIfExists)) {
|
if (options.createIfNotExists && (!structure || options.dropIfExists)) {
|
||||||
console.log(`Creating table ${fullName}`);
|
console.log(`Creating table ${fullName}`);
|
||||||
const dmp = driver.createDumper();
|
const dmp = driver.createDumper();
|
||||||
dmp.createTable({ ...writable.structure, ...name });
|
dmp.createTable(prepareTableForImport({ ...writable.structure, ...name }));
|
||||||
console.log(dmp.s);
|
console.log(dmp.s);
|
||||||
await driver.query(pool, dmp.s);
|
await driver.query(pool, dmp.s);
|
||||||
structure = await driver.analyseSingleTable(pool, name);
|
structure = await driver.analyseSingleTable(pool, name);
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
export * from './commonTypeParser';
|
export * from './commonTypeParser';
|
||||||
export * from './nameTools';
|
export * from './nameTools';
|
||||||
|
export * from './tableTransforms';
|
||||||
|
|||||||
9
packages/tools/src/tableTransforms.ts
Normal file
9
packages/tools/src/tableTransforms.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { TableInfo } from '@dbgate/types';
|
||||||
|
import _ from 'lodash';
|
||||||
|
|
||||||
|
export function prepareTableForImport(table: TableInfo): TableInfo {
|
||||||
|
const res = _.cloneDeep(table);
|
||||||
|
res.foreignKeys = [];
|
||||||
|
if (res.primaryKey) res.primaryKey.constraintName = null;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user