asciinema.org/db/migrate/20141115172153_add_secret_token_to_asciicasts.rb
Marcin Kulik 6bc2fd1048 Pad secret token correctly
After converting base 16 (hex) string of length 16 to integer and then to
base 36 we can end up with a shorter string due to implicit zeroes on
leading positions in the intermediate integer. This ensures
"00000000000000000000000000000000", "ffffffffffffffffffffffffffffffff"
and everything in between result in a string of length 25 after converting to
base 36.
2015-04-25 10:15:29 +00:00

12 lines
330 B
Ruby

class AddSecretTokenToAsciicasts < ActiveRecord::Migration
def change
add_column :asciicasts, :secret_token, :string
Asciicast.find_each do |asciicast|
asciicast.update_attribute(:secret_token, Asciicast.generate_secret_token)
end
change_column :asciicasts, :secret_token, :string, null: false
end
end