Skip to content

Commit

Permalink
chore: remove drop table check for added table (#10396)
Browse files Browse the repository at this point in the history
* chore: remove drop table check for added table

* chore: remove drop table from test

* chore: changeset
  • Loading branch information
bholmesdev authored Mar 12, 2024
1 parent 629c9d7 commit 41ca94e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/lazy-tools-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/db": patch
---

Remove risk of data loss when pushing an out-of-date table schema.
1 change: 0 additions & 1 deletion packages/db/src/core/cli/migration-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export async function getMigrationQueries({
}

for (const [collectionName, collection] of Object.entries(addedCollections)) {
queries.push(getDropTableIfExistsQuery(collectionName));
queries.push(getCreateTableQuery(collectionName, collection));
queries.push(...getCreateIndexQueries(collectionName, collection));
}
Expand Down
1 change: 0 additions & 1 deletion packages/db/test/unit/column-queries.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ describe('column queries', () => {
const newCollections = { [TABLE_NAME]: userInitial };
const { queries } = await configChangeQueries(oldCollections, newCollections);
expect(queries).to.deep.equal([
`DROP TABLE IF EXISTS "${TABLE_NAME}"`,
`CREATE TABLE "${TABLE_NAME}" (_id INTEGER PRIMARY KEY, "name" text NOT NULL, "age" integer NOT NULL, "email" text NOT NULL UNIQUE, "mi" text)`,
]);
});
Expand Down

0 comments on commit 41ca94e

Please sign in to comment.