diff options
-rw-r--r-- | .changeset/lazy-tools-reply.md | 5 | ||||
-rw-r--r-- | packages/db/src/core/cli/migration-queries.ts | 1 | ||||
-rw-r--r-- | packages/db/test/unit/column-queries.test.js | 1 |
3 files changed, 5 insertions, 2 deletions
diff --git a/.changeset/lazy-tools-reply.md b/.changeset/lazy-tools-reply.md new file mode 100644 index 000000000..fbde70cd5 --- /dev/null +++ b/.changeset/lazy-tools-reply.md @@ -0,0 +1,5 @@ +--- +"@astrojs/db": patch +--- + +Remove risk of data loss when pushing an out-of-date table schema. diff --git a/packages/db/src/core/cli/migration-queries.ts b/packages/db/src/core/cli/migration-queries.ts index 81911faae..0301d2e11 100644 --- a/packages/db/src/core/cli/migration-queries.ts +++ b/packages/db/src/core/cli/migration-queries.ts @@ -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)); } diff --git a/packages/db/test/unit/column-queries.test.js b/packages/db/test/unit/column-queries.test.js index c4b07a493..d7f65dff2 100644 --- a/packages/db/test/unit/column-queries.test.js +++ b/packages/db/test/unit/column-queries.test.js @@ -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)`, ]); }); |