mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 05:43:58 +00:00
db sync
This commit is contained in:
@@ -377,6 +377,7 @@ export function testEqualTables(
|
|||||||
) {
|
) {
|
||||||
const plan = new AlterPlan(db, driver.dialect, opts);
|
const plan = new AlterPlan(db, driver.dialect, opts);
|
||||||
planAlterTable(plan, a, b, opts);
|
planAlterTable(plan, a, b, opts);
|
||||||
|
// console.log('plan.operations', a, b, plan.operations);
|
||||||
return plan.operations.length == 0;
|
return plan.operations.length == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
export let selectable = false;
|
export let selectable = false;
|
||||||
export let selectedIndex = 0;
|
export let selectedIndex = 0;
|
||||||
export let clickable = false;
|
export let clickable = false;
|
||||||
|
export let disableFocusOutline = false;
|
||||||
|
|
||||||
export let domTable;
|
export let domTable;
|
||||||
|
|
||||||
@@ -47,6 +48,7 @@
|
|||||||
<table
|
<table
|
||||||
bind:this={domTable}
|
bind:this={domTable}
|
||||||
class:selectable
|
class:selectable
|
||||||
|
class:disableFocusOutline
|
||||||
on:keydown
|
on:keydown
|
||||||
tabindex={selectable ? -1 : undefined}
|
tabindex={selectable ? -1 : undefined}
|
||||||
on:keydown={handleKeyDown}
|
on:keydown={handleKeyDown}
|
||||||
@@ -101,6 +103,9 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
table.disableFocusOutline:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
table {
|
table {
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
<SelectField
|
<SelectField
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
value={$values[name]}
|
value={$values && $values[name]}
|
||||||
options={_.compact(options)}
|
options={_.compact(options)}
|
||||||
on:change={e => {
|
on:change={e => {
|
||||||
setFieldValue(name, e.detail);
|
setFieldValue(name, e.detail);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
export let conidName;
|
export let conidName;
|
||||||
|
|
||||||
const { values } = getFormContext();
|
const { values } = getFormContext();
|
||||||
$: databases = useDatabaseList({ conid: $values[conidName] });
|
$: databases = useDatabaseList({ conid: $values && $values[conidName] });
|
||||||
|
|
||||||
$: databaseOptions = _.sortBy(
|
$: databaseOptions = _.sortBy(
|
||||||
($databases || []).map(db => ({
|
($databases || []).map(db => ({
|
||||||
|
|||||||
@@ -3,11 +3,12 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { findEngineDriver, matchPairedObjects } from 'dbgate-tools';
|
import { findEngineDriver, generateDbPairingId, matchPairedObjects } from 'dbgate-tools';
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { writable } from 'svelte/store';
|
import { derived, writable } from 'svelte/store';
|
||||||
import TableControl from '../elements/TableControl.svelte';
|
import TableControl from '../elements/TableControl.svelte';
|
||||||
|
import FormFieldTemplateTiny from '../forms/FormFieldTemplateTiny.svelte';
|
||||||
import FormProviderCore from '../forms/FormProviderCore.svelte';
|
import FormProviderCore from '../forms/FormProviderCore.svelte';
|
||||||
import FontIcon from '../icons/FontIcon.svelte';
|
import FontIcon from '../icons/FontIcon.svelte';
|
||||||
import FormConnectionSelect from '../impexp/FormConnectionSelect.svelte';
|
import FormConnectionSelect from '../impexp/FormConnectionSelect.svelte';
|
||||||
@@ -19,36 +20,30 @@ import useEditorData from '../query/useEditorData';
|
|||||||
|
|
||||||
export let tabid;
|
export let tabid;
|
||||||
|
|
||||||
let values = writable({
|
let pairIndex = 0;
|
||||||
sourceConid: null,
|
|
||||||
sourceDatabase: null,
|
// let values = writable({
|
||||||
targetConid: null,
|
// sourceConid: null,
|
||||||
targetDatabase: null,
|
// sourceDatabase: null,
|
||||||
});
|
// targetConid: null,
|
||||||
|
// targetDatabase: null,
|
||||||
|
// });
|
||||||
|
|
||||||
const dbDiffOptions: any = {
|
const dbDiffOptions: any = {
|
||||||
ignoreCase: true,
|
// schemaMode: 'ignore',
|
||||||
schemaMode: 'ignore',
|
|
||||||
ignoreConstraintNames: true,
|
|
||||||
|
|
||||||
noDropTable: true,
|
|
||||||
noDropColumn: true,
|
|
||||||
noDropConstraint: true,
|
|
||||||
noDropSqlObject: true,
|
|
||||||
noRenameTable: true,
|
|
||||||
noRenameColumn: true,
|
|
||||||
ignoreForeignKeyActions: true,
|
|
||||||
ignoreDataTypes: true,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$: sourceDb = useDatabaseInfo({ conid: $values.sourceConid, database: $values.sourceDatabase });
|
$: sourceDbValue = useDatabaseInfo({ conid: $values?.sourceConid, database: $values?.sourceDatabase });
|
||||||
$: targetDb = useDatabaseInfo({ conid: $values.targetConid, database: $values.targetDatabase });
|
$: targetDbValue = useDatabaseInfo({ conid: $values?.targetConid, database: $values?.targetDatabase });
|
||||||
|
|
||||||
$: connection = useConnectionInfo({ conid: $values.targetConid });
|
$: sourceDb = generateDbPairingId($sourceDbValue);
|
||||||
|
$: targetDb = generateDbPairingId($targetDbValue);
|
||||||
|
|
||||||
|
$: connection = useConnectionInfo({ conid: $values?.targetConid });
|
||||||
$: driver = findEngineDriver($connection, $extensions);
|
$: driver = findEngineDriver($connection, $extensions);
|
||||||
|
|
||||||
$: targetDbPaired = matchPairedObjects($sourceDb, $targetDb, dbDiffOptions);
|
$: targetDbPaired = matchPairedObjects(sourceDb, targetDb, dbDiffOptions);
|
||||||
$: diffRows = computeDiffRows($sourceDb, targetDbPaired, dbDiffOptions, driver);
|
$: diffRows = computeDiffRows(sourceDb, targetDbPaired, dbDiffOptions, driver);
|
||||||
|
|
||||||
const { editorState, editorValue, setEditorData } = useEditorData({
|
const { editorState, editorValue, setEditorData } = useEditorData({
|
||||||
tabid,
|
tabid,
|
||||||
@@ -57,31 +52,51 @@ import useEditorData from '../query/useEditorData';
|
|||||||
// },
|
// },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const values = {
|
||||||
|
...editorValue,
|
||||||
|
update: setEditorData,
|
||||||
|
set: setEditorData,
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<FormProviderCore {values}>
|
<FormProviderCore {values}>
|
||||||
<div class="flex">
|
<div class="topbar">
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
<FormConnectionSelect name="sourceConid" label="Server" />
|
<FormConnectionSelect name="sourceConid" label="Source server" templateProps={{ noMargin: true }} isNative />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
<FormDatabaseSelect conidName="sourceConid" name="sourceDatabase" label="Database" />
|
<FormDatabaseSelect
|
||||||
|
conidName="sourceConid"
|
||||||
|
name="sourceDatabase"
|
||||||
|
label="Source database"
|
||||||
|
templateProps={{ noMargin: true }}
|
||||||
|
isNative
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="arrow">
|
<div class="arrow">
|
||||||
<FontIcon icon="icon arrow-right-bold" />
|
<FontIcon icon="icon arrow-right-bold" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
<FormConnectionSelect name="targetConid" label="Target" />
|
<FormConnectionSelect name="targetConid" label="Target server" templateProps={{ noMargin: true }} isNative />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
<FormDatabaseSelect conidName="targetConid" name="targetDatabase" label="Database" />
|
<FormDatabaseSelect
|
||||||
|
conidName="targetConid"
|
||||||
|
name="targetDatabase"
|
||||||
|
label="Target database"
|
||||||
|
templateProps={{ noMargin: true }}
|
||||||
|
isNative
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</FormProviderCore>
|
</FormProviderCore>
|
||||||
|
|
||||||
<TableControl
|
<TableControl
|
||||||
rows={diffRows}
|
rows={diffRows}
|
||||||
|
bind:selectedIndex={pairIndex}
|
||||||
|
selectable
|
||||||
|
disableFocusOutline
|
||||||
columns={[
|
columns={[
|
||||||
{ fieldName: 'type', header: 'Type' },
|
{ fieldName: 'type', header: 'Type' },
|
||||||
{ fieldName: 'sourceSchemaName', header: 'Schema' },
|
{ fieldName: 'sourceSchemaName', header: 'Schema' },
|
||||||
@@ -98,9 +113,16 @@ import useEditorData from '../query/useEditorData';
|
|||||||
overflow: auto;
|
overflow: auto;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.topbar {
|
||||||
|
display: flex;
|
||||||
|
margin: 10px 0px;
|
||||||
|
}
|
||||||
.arrow {
|
.arrow {
|
||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
color: var(--theme-icon-blue);
|
color: var(--theme-icon-blue);
|
||||||
align-self: center;
|
align-self: center;
|
||||||
|
position: relative;
|
||||||
|
top: 10px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export function computeDiffRows(
|
|||||||
opts: DbDiffOptions,
|
opts: DbDiffOptions,
|
||||||
driver: EngineDriver
|
driver: EngineDriver
|
||||||
) {
|
) {
|
||||||
if (!sourceDb || !targetDb) return [];
|
if (!sourceDb || !targetDb || !driver) return [];
|
||||||
const res = [];
|
const res = [];
|
||||||
for (const obj of sourceDb.tables) {
|
for (const obj of sourceDb.tables) {
|
||||||
const paired = targetDb.tables.find(x => x.pairingId == obj.pairingId);
|
const paired = targetDb.tables.find(x => x.pairingId == obj.pairingId);
|
||||||
|
|||||||
Reference in New Issue
Block a user