mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-24 11:45:59 +00:00
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import _ from 'lodash';
|
|
import openNewTab from '../utility/openNewTab';
|
|
import { findEngineDriver, getConnectionLabel } from 'dbgate-tools';
|
|
import { getAppliedCurrentSchema, getExtensions } from '../stores';
|
|
|
|
export default function newTable(connection, database) {
|
|
const tooltip = `${getConnectionLabel(connection)}\n${database}`;
|
|
const driver = findEngineDriver(connection, getExtensions());
|
|
openNewTab(
|
|
{
|
|
title: 'Table #',
|
|
tooltip,
|
|
icon: 'img table-structure',
|
|
tabComponent: 'TableStructureTab',
|
|
props: {
|
|
conid: connection._id,
|
|
database,
|
|
},
|
|
},
|
|
{
|
|
editor: {
|
|
current: {
|
|
pureName: 'new_table',
|
|
schemaName: getAppliedCurrentSchema() ?? driver?.dialect?.defaultSchemaName,
|
|
columns: driver.dialect?.defaultNewTableColumns ?? [
|
|
{
|
|
columnName: 'id',
|
|
dataType: 'int',
|
|
notNull: true,
|
|
autoIncrement: true,
|
|
},
|
|
],
|
|
primaryKey: {
|
|
constraintType: 'primaryKey',
|
|
columns: [
|
|
{
|
|
columnName: 'id',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
forceNewTab: true,
|
|
}
|
|
);
|
|
}
|