Sqlite preserves primary keys when copying/altering tables.

Backport #2312.
Fixes #9367.

I also added a test-case to make sure that renaming or removing
a column preserves the primary key.
Merge pull request #9388 from senny/9367_wrong_schema_after_remove_column

Sqlite preserves primary keys when copying/altering tables.