This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Inspired by http://www.madebyloren.com/posts/migrating-to-uuids-as-primary-keys | |
| task id_to_uuid: :environment do | |
| puts "[START] Convert id to uuid" | |
| ActiveRecord::Base.connection.enable_extension 'uuid-ossp' unless ActiveRecord::Base.connection.extensions.include? 'uuid-ossp' | |
| ActiveRecord::Base.connection.enable_extension 'pgcrypto' unless ActiveRecord::Base.connection.extensions.include? 'pgcrypto' | |
| table_names = ActiveRecord::Base.connection.tables - ["schema_migrations", "ar_internal_metadata", "migration_validators"] | |
| table_names.each do |table_name| | |
| puts "[CREATE] uuid column for #{table_name}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Keep code struture in models consistent | |
| # Inspired by http://rails-bestpractices.com/posts/75-keep-code-struture-in-models-consistent | |
| # One example: (From top to bottom) | |
| associations | |
| scopes | |
| class methods | |
| validates | |
| callbacks | |
| instance methods |