Last updated: November 28, 2026.
If a Doctrine schema diff treats one column of an SQLite composite primary key as auto-incrementing, check SQLite’s own metadata before applying the migration. Verify both the key columns and their order.
SELECT name, type, pk
FROM pragma_table_info('account_setting')
WHERE pk > 0
ORDER BY pk;
SELECT sql
FROM sqlite_schema
WHERE type = 'table' AND name = 'account_setting';Read the key positions
The pk field is zero for columns outside the primary key. For a key declared as PRIMARY KEY (account_id, setting_name), expect account_id to have position 1 and setting_name to have position 2. An integer column in that composite key is not an alias for SQLite’s rowid. Supply both key values on inserts unless appropriate defaults provide them.
A single column declared as INTEGER PRIMARY KEY normally aliases the rowid in a rowid table. SQLite can assign it a value even when the definition omits AUTOINCREMENT. That keyword changes rowid reuse rules and cannot turn one column of a composite key into an automatically assigned rowid. The table definition shows what SQLite actually created.
Separate a tool discrepancy from a schema change
Compare the query results with the DBAL inspection and the generated migration. If SQLite lists both columns but the migration drops one, stop the deployment and check the driver and DBAL version using a copy of the database. Keep a small schema fixture with two setting names for one account. A correct composite key permits both rows and rejects a duplicate of the same account and setting.
On a disposable database, apply the proposed migration, run the metadata query again and repeat the two-row check. This catches a migration that finishes successfully but changes the uniqueness rule.