diff --git a/README.markdown b/README.markdown index 5b57cae5..5cc9cb9d 100644 --- a/README.markdown +++ b/README.markdown @@ -16,9 +16,7 @@ Installation ============ - Add the gem to your Gemfile `gem "plutus"` - -- generate migration files `rails g plutus` - +- generate migration files `rake plutus:install:migrations` - run migrations `rake db:migrate` Overview diff --git a/lib/generators/plutus/templates/migration.rb b/db/migrate/20160422010135_create_plutus_tables.rb similarity index 87% rename from lib/generators/plutus/templates/migration.rb rename to db/migrate/20160422010135_create_plutus_tables.rb index 1879a3ab..7be31ff6 100644 --- a/lib/generators/plutus/templates/migration.rb +++ b/db/migrate/20160422010135_create_plutus_tables.rb @@ -1,5 +1,5 @@ class CreatePlutusTables < ActiveRecord::Migration[4.2] - def self.up + def change create_table :plutus_accounts do |t| t.string :name t.string :type @@ -30,10 +30,4 @@ def self.up add_index :plutus_amounts, [:account_id, :entry_id] add_index :plutus_amounts, [:entry_id, :account_id] end - - def self.down - drop_table :plutus_accounts - drop_table :plutus_entries - drop_table :plutus_amounts - end end diff --git a/fixture_rails_root/db/migrate/20170710173916_create_plutus_tables.rb b/fixture_rails_root/db/migrate/20170710173916_create_plutus_tables.rb index 7851eee3..65f09755 100644 --- a/fixture_rails_root/db/migrate/20170710173916_create_plutus_tables.rb +++ b/fixture_rails_root/db/migrate/20170710173916_create_plutus_tables.rb @@ -1,5 +1,5 @@ class CreatePlutusTables < ActiveRecord::Migration[4.2] - def self.up + def change create_table :plutus_accounts do |t| t.string :name t.string :type @@ -30,10 +30,4 @@ def self.up add_index :plutus_amounts, [:account_id, :entry_id] add_index :plutus_amounts, [:entry_id, :account_id] end - - def self.down - drop_table :plutus_accounts - drop_table :plutus_entries - drop_table :plutus_amounts - end end diff --git a/fixture_rails_root/db/migrate/20170710174915_tenant_plutus_tables.rb b/fixture_rails_root/db/migrate/20180709082453_tenant_plutus_tables.rb similarity index 100% rename from fixture_rails_root/db/migrate/20170710174915_tenant_plutus_tables.rb rename to fixture_rails_root/db/migrate/20180709082453_tenant_plutus_tables.rb diff --git a/fixture_rails_root/db/schema.rb b/fixture_rails_root/db/schema.rb index 67d7b6fa..b68be5a8 100644 --- a/fixture_rails_root/db/schema.rb +++ b/fixture_rails_root/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170710174915) do +ActiveRecord::Schema.define(version: 20180709082453) do create_table "plutus_accounts", force: :cascade do |t| t.string "name" diff --git a/lib/generators/plutus/templates/add_date_migration.rb b/lib/generators/plutus/templates/add_date_migration.rb deleted file mode 100644 index 2ba4c6ea..00000000 --- a/lib/generators/plutus/templates/add_date_migration.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddDateToPlutusEntries < ActiveRecord::Migration[4.2] - def change - add_column :plutus_entries, :date, :date - add_index :plutus_entries, :date - end -end diff --git a/lib/generators/plutus/templates/update_migration.rb b/lib/generators/plutus/templates/update_migration.rb deleted file mode 100644 index 1d86451d..00000000 --- a/lib/generators/plutus/templates/update_migration.rb +++ /dev/null @@ -1,17 +0,0 @@ -class UpdatePlutusTables < ActiveRecord::Migration[4.2] - def change - # we have to remove these indexes because the temporary - # table index name is too long - remove_index :plutus_amounts, [:account_id, :transaction_id] - remove_index :plutus_amounts, [:transaction_id, :account_id] - remove_index :plutus_transactions, column: [:commercial_document_id, :commercial_document_type], :name => "index_transactions_on_commercial_doc" - - rename_table :plutus_transactions, :plutus_entries - rename_column :plutus_amounts, :transaction_id, :entry_id - - # adding the indexes back - add_index :plutus_amounts, [:account_id, :entry_id] - add_index :plutus_amounts, [:entry_id, :account_id] - add_index :plutus_entries, [:commercial_document_id, :commercial_document_type], :name => "index_entries_on_commercial_doc" - end -end