diff --git a/sqlite_utils/db.py b/sqlite_utils/db.py index 549b39a..b653cc4 100644 --- a/sqlite_utils/db.py +++ b/sqlite_utils/db.py @@ -912,7 +912,7 @@ class Database: if missing_columns: for col_name, col_type in missing_columns.items(): table.add_column(col_name, col_type) - if missing_columns or columns_to_drop: + if missing_columns or columns_to_drop or columns != existing_columns: should_transform = True # Do we need to change the column order? if ( diff --git a/tests/test_create.py b/tests/test_create.py index 03e5781..7252e48 100644 --- a/tests/test_create.py +++ b/tests/test_create.py @@ -1176,6 +1176,13 @@ def test_create_if_no_columns(fresh_db): 'CREATE TABLE "demo" (\n [id] INTEGER PRIMARY KEY,\n [name] TEXT,\n [age] INTEGER\n)', True, ), + # Change a column type + ( + {"id": int, "name": bytes}, + {"pk": "id"}, + 'CREATE TABLE "demo" (\n [id] INTEGER PRIMARY KEY,\n [name] BLOB\n)', + True, + ), # Change the primary key ( {"id": int, "name": str},