diff --git a/src/drivers/sqlite/sqlite-generate-schema.test.ts b/src/drivers/sqlite/sqlite-generate-schema.test.ts index 3fc09a6..ca4b1c5 100644 --- a/src/drivers/sqlite/sqlite-generate-schema.test.ts +++ b/src/drivers/sqlite/sqlite-generate-schema.test.ts @@ -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"`, + ]); + }); });