Skip to content

Commit

Permalink
add more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
invisal committed Oct 1, 2024
1 parent 13cac0a commit ffc30b7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/drivers/sqlite/sqlite-generate-schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,25 @@ describe("sqlite - generate table schema", () => {
`ALTER TABLE "main"."testing" RENAME COLUMN "qty" TO "quantity"`,
]);
});

test("rename column name and change some data type", () => {
let t = c(`create table testing(id integer, qty integer, amount real)`);
t = produce(t, (draft) => {
if (draft.columns[1]?.new) {
draft.columns[1].new.name = "quantity";
draft.columns[1].new.type = "REAL";
}

if (draft.columns[2]?.new) {
draft.columns[2].new.name = "amt";
}
});

const code = generateSqlSchemaChange(t);
expect(code).toEqual([
`ALTER TABLE "main"."testing" RENAME COLUMN "qty" TO "quantity"`,
`ALTER TABLE "main"."testing" ALTER COLUMN "quantity" TO "quantity" REAL`,
`ALTER TABLE "main"."testing" RENAME COLUMN "amount" TO "amt"`,
]);
});
});

0 comments on commit ffc30b7

Please sign in to comment.