Skip to content

Commit 94e6781

Browse files
committed
Commutativity
1 parent ab4f0f0 commit 94e6781

File tree

12 files changed

+3149
-1631
lines changed

12 files changed

+3149
-1631
lines changed

drizzle-kit/src/cli/commands/check.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { readFileSync } from 'fs';
2+
import { detectNonCommutative } from 'src/utils/commutativity';
23
import type { Dialect } from '../../utils/schemaValidator';
34
import { prepareOutFolder, validatorForDialect } from '../../utils/utils-node';
45
import { info } from '../views';
5-
import { detectNonCommutative } from 'src/utils/commutativity';
66

77
export const checkHandler = async (out: string, dialect: Dialect) => {
88
const { snapshots } = prepareOutFolder(out);
99
const validator = validatorForDialect(dialect);
1010

11-
const snapshotsData: any[] = [];
11+
// const snapshotsData: PostgresSnapshot[] = [];
1212

1313
for (const snapshot of snapshots) {
1414
const raw = JSON.parse(readFileSync(`./${snapshot}`).toString());
1515

16-
snapshotsData.push(raw);
16+
// snapshotsData.push(raw);
1717

1818
const res = validator(raw);
1919
if (res.status === 'unsupported') {
@@ -36,18 +36,18 @@ export const checkHandler = async (out: string, dialect: Dialect) => {
3636
}
3737
}
3838

39-
// Non-commutative detection for branching
4039
try {
41-
const nc = await detectNonCommutative(snapshotsData, dialect);
42-
if (nc.conflicts.length > 0) {
40+
const response = await detectNonCommutative(snapshots, dialect);
41+
if (response!.conflicts.length > 0) {
4342
console.log('\nNon-commutative migration branches detected:');
44-
for (const c of nc.conflicts) {
43+
for (const c of response!.conflicts) {
4544
console.log(`- Parent ${c.parentId}${c.parentPath ? ` (${c.parentPath})` : ''}`);
4645
console.log(` A: ${c.branchA.headId} (${c.branchA.path})`);
4746
console.log(` B: ${c.branchB.headId} (${c.branchB.path})`);
4847
// for (const r of c.reasons) console.log(` • ${r}`);
4948
}
5049
}
5150
} catch (e) {
51+
console.error(e);
5252
}
5353
};

drizzle-kit/src/cli/commands/mysqlUp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { existsSync, readFileSync, rmSync, unlinkSync, writeFileSync } from 'fs';
22
import { join } from 'path';
3-
import { Column, MySqlSchemaV4, MySqlSchemaV5, mysqlSchemaV5, Table } from '../../serializer/mysqlSchema';
4-
import { Journal } from '../../utils';
3+
import type { Column, MySqlSchemaV4, MySqlSchemaV5, Table } from '../../legacy/mysql-v5/mysqlSchema';
4+
import type { Journal } from '../../utils';
55

66
export const upMysqlHandler = (out: string) => {
77
// if there is meta folder - and there is a journal - it's version <8

drizzle-kit/src/cli/commands/singlestoreUp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { existsSync, readFileSync, rmSync, unlinkSync, writeFileSync } from 'fs';
22
import { join } from 'path';
3-
import { Journal } from 'src/utils';
3+
import type { Journal } from 'src/utils';
44

55
export const upSinglestoreHandler = (out: string) => {
66
// if there is meta folder - and there is a journal - it's version <8

0 commit comments

Comments
 (0)