Skip to content

Instantly share code, notes, and snippets.

@asvechkar
Last active March 3, 2018 14:16
Show Gist options
  • Save asvechkar/6e25ad3c508a84e9102670916508d06e to your computer and use it in GitHub Desktop.
Save asvechkar/6e25ad3c508a84e9102670916508d06e to your computer and use it in GitHub Desktop.
rails generate migration enable_pgcrypto_extension
# 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