Skip to content

Commit 392125e

Browse files
eemmiillyySferaDev
authored andcommitted
fix: next build (#1472)
1 parent 937809b commit 392125e

File tree

4 files changed

+103
-117
lines changed

4 files changed

+103
-117
lines changed

cli/src/commands/schema/edit.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { beforeEach, expect, test, describe } from 'vitest';
2-
import {
2+
import { PgRollMigration } from '@xata.io/pgroll';
3+
import EditSchema, {
4+
editsToMigrations,
35
AddColumnPayload,
46
AddTablePayload,
57
ColumnAdditions,
@@ -8,9 +10,7 @@ import {
810
DeleteColumnPayload,
911
DeleteTablePayload,
1012
EditTablePayload
11-
} from './types';
12-
import { PgRollMigration } from '@xata.io/pgroll';
13-
import EditSchema, { editsToMigrations } from './edit';
13+
} from './edit';
1414

1515
const column: AddColumnPayload['column'] = {
1616
name: 'col1',

cli/src/commands/schema/edit.ts

Lines changed: 98 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,6 @@ import {
1515
} from '@xata.io/pgroll';
1616
import chalk from 'chalk';
1717
import enquirer from 'enquirer';
18-
import {
19-
AddColumnPayload,
20-
AddTablePayload,
21-
BranchSchemaFormatted,
22-
ColumnAdditions,
23-
ColumnEdits,
24-
DeleteColumnPayload,
25-
DeleteTablePayload,
26-
EditColumnPayload,
27-
EditTablePayload,
28-
SelectChoice,
29-
ValidationState
30-
} from './types.js';
3118
import {
3219
exhaustiveCheck,
3320
generateLinkReference,
@@ -42,6 +29,104 @@ import {
4229
xataColumnTypeToZeroValue
4330
} from '../../migrations/pgroll.js';
4431

32+
export type BranchSchemaFormatted =
33+
| {
34+
schema: {
35+
tables: {
36+
name: string;
37+
uniqueConstraints: Schemas.BranchSchema['tables'][number]['uniqueConstraints'];
38+
checkConstraints: Schemas.BranchSchema['tables'][number]['checkConstraints'];
39+
foreignKeys: Schemas.BranchSchema['tables'][number]['foreignKeys'];
40+
columns: {
41+
name: string;
42+
type: string;
43+
unique: boolean;
44+
notNull: boolean;
45+
defaultValue: any;
46+
comment: string;
47+
}[];
48+
}[];
49+
};
50+
}
51+
| undefined;
52+
53+
export type ColumnData = {
54+
name: string;
55+
type: string;
56+
unique: boolean;
57+
nullable: boolean;
58+
defaultValue?: string;
59+
vector?: {
60+
dimension: number;
61+
};
62+
originalName: string;
63+
tableName: string;
64+
link?: {
65+
table: string;
66+
};
67+
file?: {
68+
defaultPublicAccess: boolean;
69+
};
70+
'file[]'?: {
71+
defaultPublicAccess: boolean;
72+
};
73+
};
74+
75+
export type AddTablePayload = {
76+
type: 'add-table';
77+
table: {
78+
name: string;
79+
};
80+
};
81+
82+
export type EditTablePayload = {
83+
type: 'edit-table';
84+
table: {
85+
name: string;
86+
newName: string;
87+
};
88+
};
89+
90+
export type DeleteTablePayload = {
91+
name: string;
92+
};
93+
94+
export type AddColumnPayload = {
95+
type: 'add-column';
96+
tableName: string;
97+
column: ColumnData;
98+
};
99+
100+
export type EditColumnPayload = {
101+
type: 'edit-column';
102+
column: ColumnData;
103+
};
104+
105+
export type DeleteColumnPayload = { [tableName: string]: string[] };
106+
107+
export type FormatPayload = {
108+
type: 'space' | 'migrate' | 'schema';
109+
};
110+
111+
export type SelectChoice = {
112+
name: FormatPayload | AddTablePayload | EditTablePayload | AddColumnPayload | EditColumnPayload;
113+
message: string;
114+
role?: string;
115+
choices?: SelectChoice[];
116+
disabled?: boolean;
117+
hint?: string;
118+
};
119+
120+
export type ValidationState = {
121+
values: { name: string };
122+
items: { name: string; input: string }[];
123+
fields: { name: string; initial: string }[];
124+
};
125+
126+
export type ColumnAdditions = { [tableName: string]: { [columnName: string]: AddColumnPayload['column'] } };
127+
128+
export type ColumnEdits = { [tableName: string]: { [columnName: string]: AddColumnPayload['column'] } };
129+
45130
const { Select, Snippet, Confirm } = enquirer as any;
46131

47132
const xataTypes = [

cli/src/commands/schema/types.ts

Lines changed: 0 additions & 99 deletions
This file was deleted.

cli/src/migrations/pgroll.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { OpRawSQL, OpRenameConstraint, PgRollOperation } from '@xata.io/pgroll';
44
import path from 'path';
55
import z from 'zod';
66
import { XataClient } from '../base.js';
7-
import { BranchSchemaFormatted } from '../commands/schema/types.js';
7+
import { BranchSchemaFormatted } from '../commands/schema/edit.js';
88
import { safeJSONParse, safeReadFile } from '../utils/files.js';
99
import { migrationsDir, readMigrationsDir } from './files.js';
1010
import { MigrationFilePgroll, migrationFilePgroll } from './schema.js';

0 commit comments

Comments
 (0)