Skip to content

Commit

Permalink
Migrate direct_debit field to new DirectDebitMandate records
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Altmann committed Apr 27, 2016
1 parent a745b08 commit ebbcf02
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class CreateDirectDebitMandatesFromDirectDebitField < ActiveRecord::Migration
def up
LegalEntity.where(direct_debit: true).each do |user|
creator = CreatesDirectDebitMandate.new(user)
mandate = creator.create

# Change mandate creation date to approximate date of our SEPA mandate changeover
time = [Time.new(2015, 3, 1), user.created_at].max

mandate.created_at = time
mandate.save

user.update_fastbill_profile
end
end

def down
DirectDebitMandate.destroy_all
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160408225826) do
ActiveRecord::Schema.define(version: 20160427095019) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down

0 comments on commit ebbcf02

Please sign in to comment.