activerecord-clean-db-structure
activerecord-clean-db-structure copied to clipboard
Split primary_keys and sequences cleanups
I introduced a primary key into my schema with a character varying as datatype but still id as it's name. In order for this to work I had to disable the ignore_ids functionality, which is a shame since that functionality does a good job of cleaning up de sql file.
In order to make it work I separated the logic that handles primary keys from the logic that handles sequences. This allows to have a primary key with any datatype and any column name and still does the cleanup correctly. As a side benefit it now recognizes the primary key of the ar_internal_metadata table, which is named key instead of id.
There's still room for improvement on the sequences bit but that falls outside the scope of this PR.