This file contains 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
const encode = (data) => { | |
if(data == null) return null; | |
if(typeof data === 'number') { | |
return `i${data}e`; | |
} | |
if(typeof data === 'string') { | |
return `${data.length}:${data}`; | |
} |
This file contains 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
class Validator { | |
constructor(id, preference) { | |
this.id = id; | |
this.preference = preference; | |
this.decided = false; | |
} | |
} | |
const describeValidators = (validators) => { | |
const preferences = {}; |
This file contains 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}" |
OlderNewer