Last active
September 23, 2021 08:05
-
-
Save smapira/dc3df2f585f506a0227fe29f3baba91e to your computer and use it in GitHub Desktop.
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
namespace :db do | |
task 'migrate_custom' do | |
ActiveRecord::ConnectionAdapters::TableDefinition.prepend( | |
CoreExtensions::ActiveRecord::ConnectionAdapters::TableDefinition | |
) | |
Rake::Task['db:migrate'].invoke | |
end | |
end | |
module CoreExtensions | |
module ActiveRecord | |
module ConnectionAdapters | |
module TableDefinition | |
def coordinate(*args) | |
options = args.extract_options! | |
options.reverse_merge!({ precision: 12, scale: 7, default: 0.0 }) | |
column_names = args | |
type = :decimal | |
column_names.each { |name| column(name, type, options) } | |
end | |
def postal_code(*args) | |
options = args.extract_options! | |
options.reverse_merge!({ limit: 7, default: '', comment: '郵便番号' }) | |
column_names = args | |
type = :string | |
column_names.each { |name| column(name, type, options) } | |
end | |
def credit_card_number(*args) | |
options = args.extract_options! | |
options.reverse_merge!({ limit: 16, default: '', comment: 'クレジットカード番号' }) | |
column_names = args | |
type = :string | |
column_names.each { |name| column(name, type, options) } | |
end | |
def bank_account_number(*args) | |
options = args.extract_options! | |
options.reverse_merge!({ limit: 7, default: '', comment: '銀行口座番号' }) | |
column_names = args | |
type = :string | |
column_names.each { |name| column(name, type, options) } | |
end | |
def phone_number(*args) | |
options = args.extract_options! | |
options.reverse_merge!({ limit: 11, default: '', comment: '電話番号' }) | |
column_names = args | |
type = :string | |
column_names.each { |name| column(name, type, options) } | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment