Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add data migration gem #42

Merged
merged 8 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ gem "money-rails"

gem "net-http"

gem "data_migrate"

group :development, :test do
gem "capybara"
gem "factory_bot_rails"
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ GEM
coderay (1.1.3)
concurrent-ruby (1.2.2)
crass (1.0.6)
data_migrate (9.4.0)
activerecord (>= 6.1)
railties (>= 6.1)
date (3.3.3)
diff-lcs (1.5.0)
docile (1.4.0)
Expand Down Expand Up @@ -302,6 +305,7 @@ DEPENDENCIES
annotate
bootsnap
capybara
data_migrate
factory_bot_rails
faker
importmap-rails
Expand Down
17 changes: 17 additions & 0 deletions db/data/20240711124610_create_tax_tables.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

class CreateTaxTables < ActiveRecord::Migration[7.0]
def up
FederalTaxBracket.create(tier: "Tier 1", bottom_range: 0, top_range: 23_200, rate: 0.1, cumulative: 0)
FederalTaxBracket.create(tier: "Tier 2", bottom_range: 23_001, top_range: 94_300, rate: 0.12, cumulative: 2_320)
FederalTaxBracket.create(tier: "Tier 3", bottom_range: 94_301, top_range: 201_050, rate: 0.22, cumulative: 10_852)
FederalTaxBracket.create(tier: "Tier 4", bottom_range: 201_051, top_range: 383_900, rate: 0.24, cumulative: 34_337)
FederalTaxBracket.create(tier: "Tier 5", bottom_range: 383_901, top_range: 487_450, rate: 0.32, cumulative: 78_221)
FederalTaxBracket.create(tier: "Tier 6", bottom_range: 487_451, top_range: 731_200, rate: 0.35, cumulative: 111_357)
FederalTaxBracket.create(tier: "Tier 7", bottom_range: 731_201, top_range: 10_000_000, rate: 0.35, cumulative: 196_669)
end

def down
raise ActiveRecord::IrreversibleMigration
end
end
12 changes: 12 additions & 0 deletions db/data/20240711125841_create_incomes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

class CreateIncomes < ActiveRecord::Migration[7.0]
def up
Income.create(income_type: "Salary", rate: 100000, hours: 40, weekly_income: 1923.08)
Income.create(income_type: "Hourly", rate: 47, hours: 40, weekly_income: 1880.0)
end

def down
raise ActiveRecord::IrreversibleMigration
end
end
11 changes: 11 additions & 0 deletions db/data/20240711130514_create_expense.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

class CreateExpense < ActiveRecord::Migration[7.0]
def up
FixedExpense.create(expense_name: "Rent", annual_cost: 12000, monthly_cost: 100, bi_weekly_cost: 461.54)
end

def down
raise ActiveRecord::IrreversibleMigration
end
end
12 changes: 12 additions & 0 deletions db/data/20240711132613_create_savings_rates.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

class CreateSavingsRates < ActiveRecord::Migration[7.0]
def up
SavingsRate.create(name: "savings", rate: 0.02)
SavingsRate.create(name: "investing", rate: 0.02)
end

def down
raise ActiveRecord::IrreversibleMigration
end
end
1 change: 1 addition & 0 deletions db/data_schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DataMigrate::Data.define(version: 20240711132613)
3 changes: 3 additions & 0 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading