Skip to content

Commit 66d329f

Browse files
committed
update select prompt to be more customizable
1 parent 8ecd63f commit 66d329f

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

drizzle-kit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@drizzle-team/drizzle-kit",
3-
"version": "0.31.9",
3+
"version": "0.31.10",
44
"homepage": "https://orm.drizzle.team",
55
"keywords": [
66
"drizzle",

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

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ function tableNameWithSchemaFrom(
5757
}
5858

5959
export type SelectResolverInput = {
60-
name: string;
60+
entity: {
61+
type: 'createUniqueConstraint';
62+
name: string;
63+
count: number;
64+
tableName: string;
65+
};
6166
items: string[];
6267
};
6368

@@ -255,15 +260,19 @@ export const pgSuggestions = async (
255260
} table?\n`,
256261
);
257262

258-
const name =
259-
`You're about to add ${unsquashedUnique.name} unique constraint to the table, which contains ${count} items. If this statement fails, you will receive an error from the database. Do you want to truncate ${statement.tableName} table?`;
260-
const items = [
261-
'No, add the constraint without truncating the table',
262-
`Yes, truncate the table`,
263-
];
263+
const entity = {
264+
type: 'createUniqueConstraint' as const,
265+
name: unsquashedUnique.name,
266+
count,
267+
tableName: statement.tableName,
268+
};
269+
const items = ['no', 'yes'];
264270

265-
const { data } = selectResolver ? await selectResolver({ name, items }) : await render(
266-
new Select(items),
271+
const { data } = selectResolver ? await selectResolver({ entity, items }) : await render(
272+
new Select([
273+
'No, add the constraint without truncating the table',
274+
`Yes, truncate the table`,
275+
]),
267276
);
268277
if (data?.index === 1) {
269278
tablesToTruncate.push(statement.tableName);

0 commit comments

Comments
 (0)