diff --git a/migration/db/migrate/20190213032740_add_reorg_unique_index_from_and_to_hash.rb b/migration/db/migrate/20190213032740_add_reorg_unique_index_from_and_to_hash.rb deleted file mode 100644 index 1635ccc5..00000000 --- a/migration/db/migrate/20190213032740_add_reorg_unique_index_from_and_to_hash.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddReorgUniqueIndexFromAndToHash < ActiveRecord::Migration[5.2] - def change - add_index :reorgs, [:from_hash, :to_hash], :unique => true - end -end diff --git a/migration/db/migrate/20190220031810_add_new_reorg_table.rb b/migration/db/migrate/20190220031810_add_new_reorg_table.rb new file mode 100644 index 00000000..147703af --- /dev/null +++ b/migration/db/migrate/20190220031810_add_new_reorg_table.rb @@ -0,0 +1,14 @@ +class AddNewReorgTable < ActiveRecord::Migration[5.2] + def change + # Create new table for reorg events + create_table :reorgs2 do |t| + t.integer :from, :limit => 8, :null => false + t.binary :from_hash, :limit => 32, :null => false + t.integer :to, :limit => 8, :null => false + t.binary :to_hash, :limit => 32, :null => false + t.datetime :created_at, :null => false + end + add_index :reorgs2, [:from, :to] + add_index :reorgs2, [:from_hash, :to_hash], :unique => true + end +end diff --git a/migration/db/schema.rb b/migration/db/schema.rb index bbc063fe..43edf5ca 100644 --- a/migration/db/schema.rb +++ b/migration/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: 2019_02_13_032740) do +ActiveRecord::Schema.define(version: 2019_02_20_031810) do create_table "accounts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| t.binary "address", limit: 20, null: false @@ -97,7 +97,16 @@ t.binary "to_hash", limit: 32, null: false t.datetime "created_at", null: false t.index ["from", "to"], name: "index_reorgs_on_from_and_to" - t.index ["from_hash", "to_hash"], name: "index_reorgs_on_from_hash_and_to_hash", unique: true + end + + create_table "reorgs2", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| + t.bigint "from", null: false + t.binary "from_hash", limit: 32, null: false + t.bigint "to", null: false + t.binary "to_hash", limit: 32, null: false + t.datetime "created_at", null: false + t.index ["from", "to"], name: "index_reorgs2_on_from_and_to" + t.index ["from_hash", "to_hash"], name: "index_reorgs2_on_from_hash_and_to_hash", unique: true end create_table "subscriptions", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci", force: :cascade do |t| diff --git a/store/new_erc20_test.go b/store/new_erc20_test.go index f8339639..fee00aba 100644 --- a/store/new_erc20_test.go +++ b/store/new_erc20_test.go @@ -86,7 +86,7 @@ var _ = Describe("New ERC20 Test", func() { _, err = db.Exec("DELETE FROM total_balances") Expect(err).Should(Succeed()) - _, err = db.Exec("DELETE FROM reorgs") + _, err = db.Exec("DELETE FROM reorgs2") Expect(err).Should(Succeed()) for _, e := range erc20s { diff --git a/store/reorg/reorg.go b/store/reorg/reorg.go index 59a4f630..3037c1bf 100644 --- a/store/reorg/reorg.go +++ b/store/reorg/reorg.go @@ -33,8 +33,8 @@ type Store interface { } const ( - insertSQL = "INSERT INTO `reorgs` (`from`, `from_hash`, `to`, `to_hash`, `created_at`) VALUES (%d, X'%s', %d, X'%s', '%s')" - listSQL = "SELECT * FROM `reorgs`" + insertSQL = "INSERT INTO `reorgs2` (`from`, `from_hash`, `to`, `to_hash`, `created_at`) VALUES (%d, X'%s', %d, X'%s', '%s')" + listSQL = "SELECT * FROM `reorgs2`" ) type store struct { diff --git a/store/reorg/reorg_test.go b/store/reorg/reorg_test.go index 966e8324..23662d73 100644 --- a/store/reorg/reorg_test.go +++ b/store/reorg/reorg_test.go @@ -57,7 +57,7 @@ var _ = Describe("Reorg Database Test", func() { }) BeforeEach(func() { - _, err := db.Exec("DELETE FROM reorgs") + _, err := db.Exec("DELETE FROM reorgs2") Expect(err).Should(Succeed()) }) diff --git a/store/store_test.go b/store/store_test.go index 798e254c..f9e83aa0 100644 --- a/store/store_test.go +++ b/store/store_test.go @@ -228,7 +228,7 @@ var _ = Describe("Manager Test", func() { _, err = db.Exec("DELETE FROM total_balances") Expect(err).Should(Succeed()) - _, err = db.Exec("DELETE FROM reorgs") + _, err = db.Exec("DELETE FROM reorgs2") Expect(err).Should(Succeed()) _, err = db.Exec(fmt.Sprintf("DROP TABLE %s", model.Transfer{ diff --git a/store/transfer_processor_test.go b/store/transfer_processor_test.go index 197df42b..79d83fc9 100644 --- a/store/transfer_processor_test.go +++ b/store/transfer_processor_test.go @@ -81,7 +81,7 @@ var _ = Describe("Subscription Test", func() { _, err = db.Exec("DELETE FROM total_balances") Expect(err).Should(Succeed()) - _, err = db.Exec("DELETE FROM reorgs") + _, err = db.Exec("DELETE FROM reorgs2") Expect(err).Should(Succeed()) _, err = db.Exec(fmt.Sprintf("DROP TABLE %s", model.Transfer{