Last active
March 3, 2018 14:16
-
-
Save asvechkar/6e25ad3c508a84e9102670916508d06e to your computer and use it in GitHub Desktop.
rails generate migration enable_pgcrypto_extension
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
# enable_pgcrypto_extension.rb | |
class EnablePgcryptoExtension < ActiveRecord::Migration[5.1] | |
def change | |
enable_extension 'pgcrypto' | |
end | |
end | |
# config/application.rb | |
config.generators do |g| | |
g.orm :active_record, primary_key_type: :uuid | |
end | |
# 20160918103122_create_users.rb | |
class CreatePosts < ActiveRecord::Migration[5.1] | |
def change | |
create_table :posts, id: :uuid do |t| | |
t.string :title | |
t.timestamps | |
end | |
end | |
end | |
add_column :posts, :id, default: "uuid_generate_v4()", null: false | |
class EnablePgcryptoExtension < ActiveRecord::Migration[5.1] | |
def change | |
enable_extension 'uuid-ossp' | |
enable_extension 'pgcrypto' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment