diff --git a/Gemfile b/Gemfile index a013be501..b03462596 100644 --- a/Gemfile +++ b/Gemfile @@ -46,8 +46,7 @@ gem "redis" # , "~> 4.2.0" gem "hiredis-client" gem "digest-crc" -# Backgroud Jobs - +# Background Jobs gem "sidekiq" gem "rufus-scheduler" # bulk insertion of data into database using ActiveRecord diff --git a/README.md b/README.md index 04d57b8d3..58caded3c 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,9 @@ $ bin/setup ## Create & Setup database ```shell -bundle exec rake db:create # (create db for development and test) -bundle exec rake db:migrate # (run migration for development db) -bundle exec rake db:migrate RAILS_ENV=test # (run migration for test db) +bundle exec rake db:create # (create db for development and test) +bundle exec rake db:schema:load # (run migration for development db) +bundle exec rake db:schema:load RAILS_ENV=test # (run migration for test db) ``` ## Running Test diff --git a/app/models/ckb_sync/new_node_data_processor.rb b/app/models/ckb_sync/new_node_data_processor.rb index 57cfcc062..da6360772 100644 --- a/app/models/ckb_sync/new_node_data_processor.rb +++ b/app/models/ckb_sync/new_node_data_processor.rb @@ -782,7 +782,7 @@ def build_cells_and_locks!( if contract temp_hash = temp_hash.merge is_contract: true, contract_id: contract.id else - contract = Contract.create code_hash: lock_script.script_hash + contract = Contract.create code_hash: lock_script.code_hash temp_hash = temp_hash.merge contract_id: contract.id end script = Script.find_or_create_by temp_hash @@ -796,7 +796,7 @@ def build_cells_and_locks!( type_script_ids.each do |type_script_id| type_script = TypeScript.find(type_script_id) temp_hash = { script_hash: type_script&.script_hash, is_contract: false } - contract = Contract.find_by code_hash: type_script.code_hash + contract = Contract.find_by code_hash: type_script.script_hash if contract temp_hash = temp_hash.merge is_contract: true, contract_id: contract.id diff --git a/app/serializers/ckb_transaction_serializer.rb b/app/serializers/ckb_transaction_serializer.rb index 9218fac40..1e221fff8 100644 --- a/app/serializers/ckb_transaction_serializer.rb +++ b/app/serializers/ckb_transaction_serializer.rb @@ -11,7 +11,7 @@ class CkbTransactionSerializer end attribute :cell_deps do |o| - o.cell_dependencies.explicit.includes(:cell_output).to_a.map(&:to_raw) + o.cell_dependencies.explicit.order("id asc").includes(:cell_output).to_a.map(&:to_raw) end attribute :header_deps do |o| diff --git a/db/migrate/20190327073533_create_blocks.rb b/db/migrate/20190327073533_create_blocks.rb deleted file mode 100644 index 705b59c90..000000000 --- a/db/migrate/20190327073533_create_blocks.rb +++ /dev/null @@ -1,36 +0,0 @@ -class CreateBlocks < ActiveRecord::Migration[5.2] - def change - create_table :blocks do |t| - t.string :difficulty, limit: 66 - t.binary :block_hash - t.decimal :number, precision: 30, scale: 0 - t.binary :parent_hash - t.jsonb :seal - t.decimal :timestamp, precision: 30, scale: 0 - t.binary :transactions_root - t.binary :proposals_hash - t.integer :uncles_count - t.binary :uncles_hash - t.binary :uncle_block_hashes - t.integer :version - t.binary :proposals - t.integer :proposals_count - t.decimal :cell_consumed, precision: 30, scale: 0 - t.binary :miner_hash - t.integer :status, limit: 2 - t.decimal :reward, precision: 30 - t.decimal :total_transaction_fee, precision: 30, scale: 0 - t.decimal :ckb_transactions_count, precision: 30, scale: 0, default: 0 - t.decimal :total_cell_capacity, precision: 30, scale: 0 - t.binary :witnesses_root - t.decimal :epoch, precision: 30, scale: 0 - t.string :start_number - t.string :length - - t.timestamps - end - add_index :blocks, :block_hash, unique: true - add_index :blocks, [:block_hash, :status] - add_index :blocks, [:number, :status] - end -end \ No newline at end of file diff --git a/db/migrate/20190327073646_create_uncle_blocks.rb b/db/migrate/20190327073646_create_uncle_blocks.rb deleted file mode 100644 index 2b687f0d5..000000000 --- a/db/migrate/20190327073646_create_uncle_blocks.rb +++ /dev/null @@ -1,25 +0,0 @@ -class CreateUncleBlocks < ActiveRecord::Migration[5.2] - def change - create_table :uncle_blocks do |t| - t.string :difficulty, limit: 66 - t.binary :block_hash - t.decimal :number, precision: 30, scale: 0 - t.binary :parent_hash - t.jsonb :seal - t.decimal :timestamp, precision: 30, scale: 0 - t.binary :transactions_root - t.binary :proposals_hash - t.integer :uncles_count - t.binary :uncles_hash - t.integer :version - t.binary :proposals - t.integer :proposals_count - t.belongs_to :block, index: true - t.binary :witnesses_root - t.decimal :epoch, precision: 30, scale: 0 - - t.timestamps - end - add_index :uncle_blocks, :block_hash, unique: true - end -end diff --git a/db/migrate/20190327073737_create_ckb_transactions.rb b/db/migrate/20190327073737_create_ckb_transactions.rb deleted file mode 100644 index 7d9b04f3a..000000000 --- a/db/migrate/20190327073737_create_ckb_transactions.rb +++ /dev/null @@ -1,21 +0,0 @@ -class CreateCkbTransactions < ActiveRecord::Migration[5.2] - def change - create_table :ckb_transactions do |t| - t.binary :tx_hash - t.jsonb :deps - t.belongs_to :block, index: true - t.decimal :block_number, precision: 30, scale: 0 - t.decimal :block_timestamp, precision: 30, scale: 0 - t.jsonb :display_inputs - t.jsonb :display_outputs - t.integer :status, limit: 2 - t.decimal :transaction_fee, precision: 30, scale: 0 - t.integer :version - t.string :witnesses, array: true - - t.timestamps - end - add_index :ckb_transactions, :tx_hash, unique: true - add_index :ckb_transactions, [:tx_hash, :status] - end -end diff --git a/db/migrate/20190327073848_create_addresses.rb b/db/migrate/20190327073848_create_addresses.rb deleted file mode 100644 index 9a5a722ef..000000000 --- a/db/migrate/20190327073848_create_addresses.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateAddresses < ActiveRecord::Migration[5.2] - def change - create_table :addresses do |t| - t.decimal :balance, precision: 30, scale: 0 - t.binary :address_hash - t.decimal :cell_consumed, precision: 30, scale: 0 - t.decimal :ckb_transactions_count, precision: 30, scale: 0, default: 0 - - t.timestamps - end - add_index :addresses, :address_hash, unique: true - end -end diff --git a/db/migrate/20190327073920_create_account_books.rb b/db/migrate/20190327073920_create_account_books.rb deleted file mode 100644 index b53798a6f..000000000 --- a/db/migrate/20190327073920_create_account_books.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateAccountBooks < ActiveRecord::Migration[5.2] - def change - create_table :account_books do |t| - t.belongs_to :address, index: true - t.belongs_to :ckb_transaction, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20190327073948_create_cell_inputs.rb b/db/migrate/20190327073948_create_cell_inputs.rb deleted file mode 100644 index b2fe63301..000000000 --- a/db/migrate/20190327073948_create_cell_inputs.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateCellInputs < ActiveRecord::Migration[5.2] - def change - create_table :cell_inputs do |t| - t.jsonb :previous_output - t.string :args, array: true - t.string :since - t.belongs_to :ckb_transaction, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20190327074009_create_cell_outputs.rb b/db/migrate/20190327074009_create_cell_outputs.rb deleted file mode 100644 index 7a5d52442..000000000 --- a/db/migrate/20190327074009_create_cell_outputs.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateCellOutputs < ActiveRecord::Migration[5.2] - def change - create_table :cell_outputs do |t| - t.decimal :capacity, precision: 64, scale: 2 - t.binary :data - t.belongs_to :ckb_transaction, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20190327074053_create_lock_scripts.rb b/db/migrate/20190327074053_create_lock_scripts.rb deleted file mode 100644 index f13867aa3..000000000 --- a/db/migrate/20190327074053_create_lock_scripts.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateLockScripts < ActiveRecord::Migration[5.2] - def change - create_table :lock_scripts do |t| - t.string :args, array: true - t.binary :code_hash - t.belongs_to :cell_output, index: true - t.belongs_to :address, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20190327074129_create_type_scripts.rb b/db/migrate/20190327074129_create_type_scripts.rb deleted file mode 100644 index c821b613d..000000000 --- a/db/migrate/20190327074129_create_type_scripts.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateTypeScripts < ActiveRecord::Migration[5.2] - def change - create_table :type_scripts do |t| - t.string :args, array: true - t.binary :code_hash - t.belongs_to :cell_output, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20190327074238_create_sync_infos.rb b/db/migrate/20190327074238_create_sync_infos.rb deleted file mode 100644 index 96efd1411..000000000 --- a/db/migrate/20190327074238_create_sync_infos.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateSyncInfos < ActiveRecord::Migration[5.2] - def change - create_table :sync_infos do |t| - t.string :name - t.decimal :value, precision: 30, scale: 0 - t.integer :status, limit: 2 - - t.timestamps - end - add_index :sync_infos, [:name, :status] - add_index :sync_infos, [:name, :value], unique: true - end -end diff --git a/db/migrate/20190428084336_add_status_to_cell_output.rb b/db/migrate/20190428084336_add_status_to_cell_output.rb deleted file mode 100644 index ff6f1948e..000000000 --- a/db/migrate/20190428084336_add_status_to_cell_output.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddStatusToCellOutput < ActiveRecord::Migration[5.2] - def change - add_column :cell_outputs, :status, :integer, limit: 2, default: 0 - end -end diff --git a/db/migrate/20190428094733_add_address_id_to_cell_output.rb b/db/migrate/20190428094733_add_address_id_to_cell_output.rb deleted file mode 100644 index d5a3ca0f2..000000000 --- a/db/migrate/20190428094733_add_address_id_to_cell_output.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddAddressIdToCellOutput < ActiveRecord::Migration[5.2] - def change - add_column :cell_outputs, :address_id, :decimal, precision: 30, scale: 0 - end -end diff --git a/db/migrate/20190505080010_add_display_input_and_fee_status_to_ckb_transaction.rb b/db/migrate/20190505080010_add_display_input_and_fee_status_to_ckb_transaction.rb deleted file mode 100644 index ef5824a42..000000000 --- a/db/migrate/20190505080010_add_display_input_and_fee_status_to_ckb_transaction.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddDisplayInputAndFeeStatusToCkbTransaction < ActiveRecord::Migration[5.2] - def change - add_column :ckb_transactions, :display_inputs_status, :integer, limit: 2, default: 0 - add_column :ckb_transactions, :transaction_fee_status, :integer, limit: 2, default: 0 - - add_index :ckb_transactions, :display_inputs_status - add_index :ckb_transactions, :transaction_fee_status - end -end diff --git a/db/migrate/20190507083006_add_block_id_to_cell_outputs.rb b/db/migrate/20190507083006_add_block_id_to_cell_outputs.rb deleted file mode 100644 index 3afa06717..000000000 --- a/db/migrate/20190507083006_add_block_id_to_cell_outputs.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddBlockIdToCellOutputs < ActiveRecord::Migration[5.2] - def change - add_column :cell_outputs, :block_id, :decimal, precision: 30, scale: 0 - - add_index :cell_outputs, :block_id - end -end diff --git a/db/migrate/20190507085943_add_index_to_address_id_on_cell_outputs.rb b/db/migrate/20190507085943_add_index_to_address_id_on_cell_outputs.rb deleted file mode 100644 index a237c26dd..000000000 --- a/db/migrate/20190507085943_add_index_to_address_id_on_cell_outputs.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIndexToAddressIdOnCellOutputs < ActiveRecord::Migration[5.2] - def change - add_index :cell_outputs, :address_id - end -end diff --git a/db/migrate/20190520025819_change_unique_index_scope.rb b/db/migrate/20190520025819_change_unique_index_scope.rb deleted file mode 100644 index 269606b7e..000000000 --- a/db/migrate/20190520025819_change_unique_index_scope.rb +++ /dev/null @@ -1,9 +0,0 @@ -class ChangeUniqueIndexScope < ActiveRecord::Migration[5.2] - def change - remove_index :uncle_blocks, name: :index_uncle_blocks_on_block_hash, column: :block_hash - add_index :uncle_blocks, [:block_hash, :block_id], unique: true - - remove_index :ckb_transactions, name: :index_ckb_transactions_on_tx_hash, column: :tx_hash - add_index :ckb_transactions, [:tx_hash, :block_id], unique: true - end -end diff --git a/db/migrate/20190521045538_add_address_ids_to_block.rb b/db/migrate/20190521045538_add_address_ids_to_block.rb deleted file mode 100644 index 679e844b7..000000000 --- a/db/migrate/20190521045538_add_address_ids_to_block.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddAddressIdsToBlock < ActiveRecord::Migration[5.2] - def change - add_column :blocks, :address_ids, :string, array: true - end -end diff --git a/db/migrate/20190521075501_add_index_on_status_to_cell_outputs.rb b/db/migrate/20190521075501_add_index_on_status_to_cell_outputs.rb deleted file mode 100644 index 969c89281..000000000 --- a/db/migrate/20190521075501_add_index_on_status_to_cell_outputs.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddIndexOnStatusToCellOutputs < ActiveRecord::Migration[5.2] - def change - remove_index :cell_outputs, name: :index_cell_outputs_on_address_id, column: :address_id - add_index :cell_outputs, [:address_id, :status] - end -end diff --git a/db/migrate/20190522092518_add_tx_hash_and_cell_index_to_cell_outputs.rb b/db/migrate/20190522092518_add_tx_hash_and_cell_index_to_cell_outputs.rb deleted file mode 100644 index f049b3130..000000000 --- a/db/migrate/20190522092518_add_tx_hash_and_cell_index_to_cell_outputs.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddTxHashAndCellIndexToCellOutputs < ActiveRecord::Migration[5.2] - def change - add_column :cell_outputs, :tx_hash, :binary - add_column :cell_outputs, :cell_index, :integer - - add_index :cell_outputs, [:tx_hash, :cell_index] - end -end diff --git a/db/migrate/20190522093025_add_previous_cell_output_id_to_cell_inputs.rb b/db/migrate/20190522093025_add_previous_cell_output_id_to_cell_inputs.rb deleted file mode 100644 index 42286f996..000000000 --- a/db/migrate/20190522093025_add_previous_cell_output_id_to_cell_inputs.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddPreviousCellOutputIdToCellInputs < ActiveRecord::Migration[5.2] - def change - add_column :cell_inputs, :previous_cell_output_id, :bigint - - add_index :cell_inputs, :previous_cell_output_id - end -end diff --git a/db/migrate/20190527105726_add_from_cell_base_to_cell_inputs.rb b/db/migrate/20190527105726_add_from_cell_base_to_cell_inputs.rb deleted file mode 100644 index 19406d935..000000000 --- a/db/migrate/20190527105726_add_from_cell_base_to_cell_inputs.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddFromCellBaseToCellInputs < ActiveRecord::Migration[5.2] - def change - add_column :cell_inputs, :from_cell_base, :boolean, default: false - end -end diff --git a/db/migrate/20190528014728_update_from_cell_base_for_exist_cell_inputs.rb b/db/migrate/20190528014728_update_from_cell_base_for_exist_cell_inputs.rb deleted file mode 100644 index c3e42b58a..000000000 --- a/db/migrate/20190528014728_update_from_cell_base_for_exist_cell_inputs.rb +++ /dev/null @@ -1,6 +0,0 @@ -class UpdateFromCellBaseForExistCellInputs < ActiveRecord::Migration[5.2] - def up - CellInput.where("previous_output @> ?", { cell: nil }.to_json).update_all(from_cell_base: true) - CellInput.where.not("previous_output @> ?", { cell: nil }.to_json).update_all(from_cell_base: false) - end -end diff --git a/db/migrate/20190530090537_add_lock_hash_to_address.rb b/db/migrate/20190530090537_add_lock_hash_to_address.rb deleted file mode 100644 index b115169f5..000000000 --- a/db/migrate/20190530090537_add_lock_hash_to_address.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddLockHashToAddress < ActiveRecord::Migration[5.2] - def change - add_column :addresses, :lock_hash, :binary - - add_index :addresses, :lock_hash, unique: true - end -end diff --git a/db/migrate/20190531030940_remove_unique_index_on_address_hash_from_address.rb b/db/migrate/20190531030940_remove_unique_index_on_address_hash_from_address.rb deleted file mode 100644 index 6d49eeb45..000000000 --- a/db/migrate/20190531030940_remove_unique_index_on_address_hash_from_address.rb +++ /dev/null @@ -1,6 +0,0 @@ -class RemoveUniqueIndexOnAddressHashFromAddress < ActiveRecord::Migration[5.2] - def change - remove_index :addresses, :address_hash - add_index :addresses, :address_hash - end -end diff --git a/db/migrate/20190604062236_add_is_cellbase_to_ckb_transactions.rb b/db/migrate/20190604062236_add_is_cellbase_to_ckb_transactions.rb deleted file mode 100644 index b64bdecb6..000000000 --- a/db/migrate/20190604062236_add_is_cellbase_to_ckb_transactions.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddIsCellbaseToCkbTransactions < ActiveRecord::Migration[5.2] - def change - add_column :ckb_transactions, :is_cellbase, :boolean, default: false - add_index :ckb_transactions, :is_cellbase - end -end diff --git a/db/migrate/20190606083952_remove_args_from_cell_inputs.rb b/db/migrate/20190606083952_remove_args_from_cell_inputs.rb deleted file mode 100644 index fe13c7f81..000000000 --- a/db/migrate/20190606083952_remove_args_from_cell_inputs.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RemoveArgsFromCellInputs < ActiveRecord::Migration[5.2] - def change - remove_column :cell_inputs, :args - end -end diff --git a/db/migrate/20190612034620_add_index_on_status_to_blocks.rb b/db/migrate/20190612034620_add_index_on_status_to_blocks.rb deleted file mode 100644 index be11ee2b2..000000000 --- a/db/migrate/20190612034620_add_index_on_status_to_blocks.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddIndexOnStatusToBlocks < ActiveRecord::Migration[5.2] - disable_ddl_transaction! - - def change - add_index :blocks, :status, algorithm: :concurrently - add_index :blocks, :timestamp, algorithm: :concurrently - end -end diff --git a/db/migrate/20190617015612_remove_indexes_from_blocks.rb b/db/migrate/20190617015612_remove_indexes_from_blocks.rb deleted file mode 100644 index 30efbdaa8..000000000 --- a/db/migrate/20190617015612_remove_indexes_from_blocks.rb +++ /dev/null @@ -1,7 +0,0 @@ -class RemoveIndexesFromBlocks < ActiveRecord::Migration[5.2] - def change - remove_index :blocks, name: "index_blocks_on_block_hash_and_status", column: [:block_hash, :status] - remove_index :blocks, name: "index_blocks_on_number_and_status", column: [:number, :status] - remove_index :blocks, name: "index_blocks_on_status", column: :status - end -end diff --git a/db/migrate/20190617015805_add_index_on_number_to_blocks.rb b/db/migrate/20190617015805_add_index_on_number_to_blocks.rb deleted file mode 100644 index 0a666d672..000000000 --- a/db/migrate/20190617015805_add_index_on_number_to_blocks.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIndexOnNumberToBlocks < ActiveRecord::Migration[5.2] - def change - add_index :blocks, :number - end -end diff --git a/db/migrate/20190618154208_remove_tx_hash_and_status_index_on_ckb_transactions.rb b/db/migrate/20190618154208_remove_tx_hash_and_status_index_on_ckb_transactions.rb deleted file mode 100644 index f0b93dd74..000000000 --- a/db/migrate/20190618154208_remove_tx_hash_and_status_index_on_ckb_transactions.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RemoveTxHashAndStatusIndexOnCkbTransactions < ActiveRecord::Migration[5.2] - def change - remove_index :ckb_transactions, name: "index_ckb_transactions_on_tx_hash_and_status", column: [:tx_hash, :status] - end -end diff --git a/db/migrate/20190618154444_add_index_on_block_timestamp_to_ckb_transactions.rb b/db/migrate/20190618154444_add_index_on_block_timestamp_to_ckb_transactions.rb deleted file mode 100644 index ced8571e2..000000000 --- a/db/migrate/20190618154444_add_index_on_block_timestamp_to_ckb_transactions.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddIndexOnBlockTimestampToCkbTransactions < ActiveRecord::Migration[5.2] - def change - remove_index :ckb_transactions, name: "index_ckb_transactions_on_block_id", column: :block_id - add_index :ckb_transactions, [:block_id, :block_timestamp] - end -end diff --git a/db/migrate/20190625075829_add_reward_status_to_blocks.rb b/db/migrate/20190625075829_add_reward_status_to_blocks.rb deleted file mode 100644 index b74f69135..000000000 --- a/db/migrate/20190625075829_add_reward_status_to_blocks.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddRewardStatusToBlocks < ActiveRecord::Migration[5.2] - def change - add_column :blocks, :reward_status, :integer, default: 0 - end -end diff --git a/db/migrate/20190625093219_add_received_tx_fee_status_to_blocks.rb b/db/migrate/20190625093219_add_received_tx_fee_status_to_blocks.rb deleted file mode 100644 index ff5fed80b..000000000 --- a/db/migrate/20190625093219_add_received_tx_fee_status_to_blocks.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddReceivedTxFeeStatusToBlocks < ActiveRecord::Migration[5.2] - def change - add_column :blocks, :received_tx_fee_status, :integer, default: 0 - end -end diff --git a/db/migrate/20190625093335_add_received_tx_fee_to_blocks.rb b/db/migrate/20190625093335_add_received_tx_fee_to_blocks.rb deleted file mode 100644 index 07a1bd69e..000000000 --- a/db/migrate/20190625093335_add_received_tx_fee_to_blocks.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddReceivedTxFeeToBlocks < ActiveRecord::Migration[5.2] - def change - add_column :blocks, :received_tx_fee, :decimal, precision: 30, scale: 0, default: 0 - end -end diff --git a/db/migrate/20190626085513_add_pending_reward_blocks_count_to_addresses.rb b/db/migrate/20190626085513_add_pending_reward_blocks_count_to_addresses.rb deleted file mode 100644 index 1fc5bd39a..000000000 --- a/db/migrate/20190626085513_add_pending_reward_blocks_count_to_addresses.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddPendingRewardBlocksCountToAddresses < ActiveRecord::Migration[5.2] - def change - add_column :addresses, :pending_reward_blocks_count, :integer, default: 0 - end -end diff --git a/db/migrate/20190628052742_add_target_block_reward_status_to_blocks.rb b/db/migrate/20190628052742_add_target_block_reward_status_to_blocks.rb deleted file mode 100644 index f0e413039..000000000 --- a/db/migrate/20190628052742_add_target_block_reward_status_to_blocks.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddTargetBlockRewardStatusToBlocks < ActiveRecord::Migration[5.2] - def change - add_column :blocks, :target_block_reward_status, :integer, default: 0 - end -end diff --git a/db/migrate/20190703102751_add_status_to_uncle_blocks.rb b/db/migrate/20190703102751_add_status_to_uncle_blocks.rb deleted file mode 100644 index 2f7bbe895..000000000 --- a/db/migrate/20190703102751_add_status_to_uncle_blocks.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddStatusToUncleBlocks < ActiveRecord::Migration[5.2] - def change - add_column :uncle_blocks, :status, :integer, default: 0 - end -end diff --git a/db/migrate/20190705084121_add_generated_by_and_consumed_by_id_to_cell_outputs.rb b/db/migrate/20190705084121_add_generated_by_and_consumed_by_id_to_cell_outputs.rb deleted file mode 100644 index f56aec56b..000000000 --- a/db/migrate/20190705084121_add_generated_by_and_consumed_by_id_to_cell_outputs.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddGeneratedByAndConsumedByIdToCellOutputs < ActiveRecord::Migration[5.2] - def change - add_column :cell_outputs, :generated_by_id, :decimal, precision: 30, scale: 0 - add_column :cell_outputs, :consumed_by_id, :decimal, precision: 30, scale: 0 - - add_index :cell_outputs, :generated_by_id - add_index :cell_outputs, :consumed_by_id - end -end diff --git a/db/migrate/20190708060254_add_block_id_to_cell_inputs.rb b/db/migrate/20190708060254_add_block_id_to_cell_inputs.rb deleted file mode 100644 index 92216d997..000000000 --- a/db/migrate/20190708060254_add_block_id_to_cell_inputs.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddBlockIdToCellInputs < ActiveRecord::Migration[5.2] - def change - add_column :cell_inputs, :block_id, :decimal, precision: 30, scale: 0 - - add_index :cell_inputs, :block_id - end -end diff --git a/db/migrate/20190711102928_add_miner_lock_hash_to_blocks.rb b/db/migrate/20190711102928_add_miner_lock_hash_to_blocks.rb deleted file mode 100644 index 0dffa1cae..000000000 --- a/db/migrate/20190711102928_add_miner_lock_hash_to_blocks.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddMinerLockHashToBlocks < ActiveRecord::Migration[5.2] - def change - add_column :blocks, :miner_lock_hash, :binary - end -end diff --git a/db/migrate/20190722051936_add_hash_type_to_scripts.rb b/db/migrate/20190722051936_add_hash_type_to_scripts.rb deleted file mode 100644 index 9b0bbe403..000000000 --- a/db/migrate/20190722051936_add_hash_type_to_scripts.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddHashTypeToScripts < ActiveRecord::Migration[5.2] - def change - add_column :lock_scripts, :hash_type, :string - add_column :type_scripts, :hash_type, :string - end -end diff --git a/db/migrate/20190724053202_add_dao_to_blocks.rb b/db/migrate/20190724053202_add_dao_to_blocks.rb deleted file mode 100644 index b390a8762..000000000 --- a/db/migrate/20190724053202_add_dao_to_blocks.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddDaoToBlocks < ActiveRecord::Migration[5.2] - def change - add_column :blocks, :dao, :string - end -end diff --git a/db/migrate/20190725014432_add_dao_to_uncle_blocks.rb b/db/migrate/20190725014432_add_dao_to_uncle_blocks.rb deleted file mode 100644 index f7bb57439..000000000 --- a/db/migrate/20190725014432_add_dao_to_uncle_blocks.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddDaoToUncleBlocks < ActiveRecord::Migration[5.2] - def change - add_column :uncle_blocks, :dao, :string - end -end diff --git a/db/migrate/20190731111218_remove_sync_infos.rb b/db/migrate/20190731111218_remove_sync_infos.rb deleted file mode 100644 index 97c4515fb..000000000 --- a/db/migrate/20190731111218_remove_sync_infos.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RemoveSyncInfos < ActiveRecord::Migration[5.2] - def change - drop_table :sync_infos - end -end diff --git a/db/migrate/20190731111431_remove_useless_column_from_ckb_transactions.rb b/db/migrate/20190731111431_remove_useless_column_from_ckb_transactions.rb deleted file mode 100644 index 8f0cd734d..000000000 --- a/db/migrate/20190731111431_remove_useless_column_from_ckb_transactions.rb +++ /dev/null @@ -1,9 +0,0 @@ -class RemoveUselessColumnFromCkbTransactions < ActiveRecord::Migration[5.2] - def change - remove_column :ckb_transactions, :status, :integer - remove_column :ckb_transactions, :display_inputs_status, :integer - remove_column :ckb_transactions, :transaction_fee_status, :integer - remove_column :ckb_transactions, :display_inputs, :jsonb - remove_column :ckb_transactions, :display_outputs, :jsonb - end -end diff --git a/db/migrate/20190731112207_remove_status_from_uncle_blocks.rb b/db/migrate/20190731112207_remove_status_from_uncle_blocks.rb deleted file mode 100644 index 300bd32b6..000000000 --- a/db/migrate/20190731112207_remove_status_from_uncle_blocks.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RemoveStatusFromUncleBlocks < ActiveRecord::Migration[5.2] - def change - remove_column :uncle_blocks, :status, :integer - end -end diff --git a/db/migrate/20190809023059_add_cell_type_to_cell_outputs.rb b/db/migrate/20190809023059_add_cell_type_to_cell_outputs.rb deleted file mode 100644 index 40835807b..000000000 --- a/db/migrate/20190809023059_add_cell_type_to_cell_outputs.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCellTypeToCellOutputs < ActiveRecord::Migration[5.2] - def change - add_column :cell_outputs, :cell_type, :integer, default: 0 - end -end diff --git a/db/migrate/20190810071407_change_unique_index_scope_on_block_hash.rb b/db/migrate/20190810071407_change_unique_index_scope_on_block_hash.rb deleted file mode 100644 index 8cda51161..000000000 --- a/db/migrate/20190810071407_change_unique_index_scope_on_block_hash.rb +++ /dev/null @@ -1,6 +0,0 @@ -class ChangeUniqueIndexScopeOnBlockHash < ActiveRecord::Migration[5.2] - def change - remove_index :blocks, name: :index_blocks_on_block_hash, column: :block_hash - add_index :blocks, [:block_hash, :status], unique: true - end -end diff --git a/db/migrate/20190813074456_add_header_deps_and_cell_deps_to_ckb_transactions.rb b/db/migrate/20190813074456_add_header_deps_and_cell_deps_to_ckb_transactions.rb deleted file mode 100644 index 029dd46be..000000000 --- a/db/migrate/20190813074456_add_header_deps_and_cell_deps_to_ckb_transactions.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddHeaderDepsAndCellDepsToCkbTransactions < ActiveRecord::Migration[5.2] - def change - add_column :ckb_transactions, :header_deps, :binary - add_column :ckb_transactions, :cell_deps, :jsonb - end -end diff --git a/db/migrate/20190816092434_change_unique_index_on_block.rb b/db/migrate/20190816092434_change_unique_index_on_block.rb deleted file mode 100644 index d825a3ae6..000000000 --- a/db/migrate/20190816092434_change_unique_index_on_block.rb +++ /dev/null @@ -1,6 +0,0 @@ -class ChangeUniqueIndexOnBlock < ActiveRecord::Migration[5.2] - def change - remove_index :blocks, column: [:block_hash, :status] - add_index :blocks, :block_hash, unique: true - end -end diff --git a/db/migrate/20190816092718_remove_status_from_blocks.rb b/db/migrate/20190816092718_remove_status_from_blocks.rb deleted file mode 100644 index 6a592931b..000000000 --- a/db/migrate/20190816092718_remove_status_from_blocks.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RemoveStatusFromBlocks < ActiveRecord::Migration[5.2] - def change - remove_column :blocks, :status - end -end diff --git a/db/migrate/20190816102847_create_forked_blocks.rb b/db/migrate/20190816102847_create_forked_blocks.rb deleted file mode 100644 index 9382a0b5d..000000000 --- a/db/migrate/20190816102847_create_forked_blocks.rb +++ /dev/null @@ -1,39 +0,0 @@ -class CreateForkedBlocks < ActiveRecord::Migration[5.2] - def change - create_table :forked_blocks do |t| - t.string :difficulty, limit: 66 - t.binary :block_hash - t.decimal :number, precision: 30, scale: 0 - t.binary :parent_hash - t.jsonb :seal - t.decimal :timestamp, precision: 30, scale: 0 - t.binary :transactions_root - t.binary :proposals_hash - t.integer :uncles_count - t.binary :uncles_hash - t.binary :uncle_block_hashes - t.integer :version - t.binary :proposals - t.integer :proposals_count - t.decimal :cell_consumed, precision: 30, scale: 0 - t.binary :miner_hash - t.decimal :reward, precision: 30 - t.decimal :total_transaction_fee, precision: 30, scale: 0 - t.decimal :ckb_transactions_count, precision: 30, scale: 0, default: 0 - t.decimal :total_cell_capacity, precision: 30, scale: 0 - t.binary :witnesses_root - t.decimal :epoch, precision: 30, scale: 0 - t.string :start_number - t.string :length - t.string :address_ids, array: true - t.integer :reward_status, default: 0 - t.integer :received_tx_fee_status, default: 0 - t.decimal :received_tx_fee, precision: 30, scale: 0, default: 0 - t.integer :target_block_reward_status, default: 0 - t.binary :miner_lock_hash - t.string :dao - - t.timestamps - end - end -end diff --git a/db/migrate/20190819090938_change_witnesses_to_jsonb_in_ckb_transactions.rb b/db/migrate/20190819090938_change_witnesses_to_jsonb_in_ckb_transactions.rb deleted file mode 100644 index d3139c59f..000000000 --- a/db/migrate/20190819090938_change_witnesses_to_jsonb_in_ckb_transactions.rb +++ /dev/null @@ -1,6 +0,0 @@ -class ChangeWitnessesToJsonbInCkbTransactions < ActiveRecord::Migration[5.2] - def change - remove_column :ckb_transactions, :witnesses, :jsonb - add_column :ckb_transactions, :witnesses, :jsonb - end -end diff --git a/db/migrate/20190823015148_add_primary_reward_and_secondary_reward_to_blocks.rb b/db/migrate/20190823015148_add_primary_reward_and_secondary_reward_to_blocks.rb deleted file mode 100644 index a1f72b60c..000000000 --- a/db/migrate/20190823015148_add_primary_reward_and_secondary_reward_to_blocks.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddPrimaryRewardAndSecondaryRewardToBlocks < ActiveRecord::Migration[5.2] - def change - add_column :blocks, :primary_reward, :decimal, precision: 30, scale: 0, default: 0 - add_column :blocks, :secondary_reward, :decimal, precision: 30, scale: 0, default: 0 - end -end diff --git a/db/migrate/20190823031706_add_primary_reward_and_secondary_reward_to_forked_blocks.rb b/db/migrate/20190823031706_add_primary_reward_and_secondary_reward_to_forked_blocks.rb deleted file mode 100644 index e13ef2c2f..000000000 --- a/db/migrate/20190823031706_add_primary_reward_and_secondary_reward_to_forked_blocks.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddPrimaryRewardAndSecondaryRewardToForkedBlocks < ActiveRecord::Migration[5.2] - def change - add_column :forked_blocks, :primary_reward, :decimal, precision: 30, scale: 0, default: 0 - add_column :forked_blocks, :secondary_reward, :decimal, precision: 30, scale: 0, default: 0 - end -end diff --git a/db/migrate/20190824025831_remove_seal_from_blocks.rb b/db/migrate/20190824025831_remove_seal_from_blocks.rb deleted file mode 100644 index 05d33613f..000000000 --- a/db/migrate/20190824025831_remove_seal_from_blocks.rb +++ /dev/null @@ -1,11 +0,0 @@ -class RemoveSealFromBlocks < ActiveRecord::Migration[5.2] - def change - remove_column :blocks, :seal - remove_column :forked_blocks, :seal - remove_column :uncle_blocks, :seal - - add_column :blocks, :nonce, :string - add_column :forked_blocks, :nonce, :string - add_column :uncle_blocks, :nonce, :string - end -end diff --git a/db/migrate/20190916094321_change_difficulty_nonce_and_since_to_decimal.rb b/db/migrate/20190916094321_change_difficulty_nonce_and_since_to_decimal.rb deleted file mode 100644 index 340aa1f52..000000000 --- a/db/migrate/20190916094321_change_difficulty_nonce_and_since_to_decimal.rb +++ /dev/null @@ -1,29 +0,0 @@ -class ChangeDifficultyNonceAndSinceToDecimal < ActiveRecord::Migration[6.0] - def change - remove_column :blocks, :difficulty, :string - remove_column :blocks, :nonce, :string - remove_column :blocks, :start_number, :string - remove_column :blocks, :length, :string - add_column :blocks, :difficulty, :decimal, precision: 80, scale: 0, default: 0 - add_column :blocks, :nonce, :decimal, precision: 30, scale: 0, default: 0 - add_column :blocks, :start_number, :decimal, precision: 30, scale: 0, default: 0 - add_column :blocks, :length, :decimal, precision: 30, scale: 0, default: 0 - - remove_column :uncle_blocks, :difficulty, :string - remove_column :uncle_blocks, :nonce, :string - add_column :uncle_blocks, :difficulty, :decimal, precision: 80, scale: 0, default: 0 - add_column :uncle_blocks, :nonce, :decimal, precision: 30, scale: 0, default: 0 - - remove_column :forked_blocks, :difficulty, :string - remove_column :forked_blocks, :nonce, :string - remove_column :forked_blocks, :start_number, :string - remove_column :forked_blocks, :length, :string - add_column :forked_blocks, :difficulty, :decimal, precision: 80, scale: 0, default: 0 - add_column :forked_blocks, :nonce, :decimal, precision: 30, scale: 0, default: 0 - add_column :forked_blocks, :start_number, :decimal, precision: 30, scale: 0, default: 0 - add_column :forked_blocks, :length, :decimal, precision: 30, scale: 0, default: 0 - - remove_column :cell_inputs, :since, :string - add_column :cell_inputs, :since, :decimal, precision: 30, scale: 0, default: 0 - end -end diff --git a/db/migrate/20190929032339_replace_difficulty_with_compact_target.rb b/db/migrate/20190929032339_replace_difficulty_with_compact_target.rb deleted file mode 100644 index f279d830e..000000000 --- a/db/migrate/20190929032339_replace_difficulty_with_compact_target.rb +++ /dev/null @@ -1,16 +0,0 @@ -class ReplaceDifficultyWithCompactTarget < ActiveRecord::Migration[6.0] - def change - remove_column :blocks, :witnesses_root, :binary - remove_column :blocks, :difficulty, :decimal - add_column :blocks, :compact_target, :decimal, precision: 20, scale: 0 - - remove_column :uncle_blocks, :witnesses_root, :binary - remove_column :uncle_blocks, :uncles_count, :integer - remove_column :uncle_blocks, :difficulty, :decimal - add_column :uncle_blocks, :compact_target, :decimal, precision: 20, scale: 0 - - remove_column :forked_blocks, :witnesses_root, :binary - remove_column :forked_blocks, :difficulty, :decimal - add_column :forked_blocks, :compact_target, :decimal, precision: 20, scale: 0 - end -end diff --git a/db/migrate/20190930025437_change_args_column_type_to_string.rb b/db/migrate/20190930025437_change_args_column_type_to_string.rb deleted file mode 100644 index 06e9a3f04..000000000 --- a/db/migrate/20190930025437_change_args_column_type_to_string.rb +++ /dev/null @@ -1,6 +0,0 @@ -class ChangeArgsColumnTypeToString < ActiveRecord::Migration[6.0] - def change - change_column :lock_scripts, :args, :string - change_column :type_scripts, :args, :string - end -end diff --git a/db/migrate/20191004060003_change_nonce_precision.rb b/db/migrate/20191004060003_change_nonce_precision.rb deleted file mode 100644 index 0f4ba060e..000000000 --- a/db/migrate/20191004060003_change_nonce_precision.rb +++ /dev/null @@ -1,17 +0,0 @@ -class ChangeNoncePrecision < ActiveRecord::Migration[6.0] - def change - reversible do |dir| - dir.up do - change_column :blocks, :nonce, :decimal, precision: 50, scale: 0, default: 0 - change_column :uncle_blocks, :nonce, :decimal, precision: 50, scale: 0, default: 0 - change_column :forked_blocks, :nonce, :decimal, precision: 50, scale: 0, default: 0 - end - - dir.down do - change_column :blocks, :nonce, :decimal, precision: 30, scale: 0, default: 0 - change_column :uncle_blocks, :nonce, :decimal, precision: 30, scale: 0, default: 0 - change_column :forked_blocks, :nonce, :decimal, precision: 30, scale: 0, default: 0 - end - end - end -end diff --git a/db/migrate/20191009075035_add_dao_deposit_and_subsidy_to_addresses.rb b/db/migrate/20191009075035_add_dao_deposit_and_subsidy_to_addresses.rb deleted file mode 100644 index a0c508388..000000000 --- a/db/migrate/20191009075035_add_dao_deposit_and_subsidy_to_addresses.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddDaoDepositAndSubsidyToAddresses < ActiveRecord::Migration[6.0] - def change - add_column :addresses, :dao_deposit, :decimal, precision: 30, scale: 0, default: 0 - add_column :addresses, :subsidy, :decimal, precision: 30, scale: 0, default: 0 - end -end diff --git a/db/migrate/20191009081603_create_dao_contracts.rb b/db/migrate/20191009081603_create_dao_contracts.rb deleted file mode 100644 index 1a57d27ac..000000000 --- a/db/migrate/20191009081603_create_dao_contracts.rb +++ /dev/null @@ -1,15 +0,0 @@ -class CreateDaoContracts < ActiveRecord::Migration[6.0] - def change - create_table :dao_contracts do |t| - t.decimal "total_deposit", precision: 30, default: "0" - t.decimal "subsidy_granted", precision: 30, default: "0" - t.bigint "deposit_transactions_count", default: "0" - t.bigint "withdraw_transactions_count", default: "0" - t.integer "depositors_count", default: "0" - t.bigint "total_depositors_count", default: "0" - t.references - - t.timestamps - end - end -end diff --git a/db/migrate/20191009083202_create_dao_events.rb b/db/migrate/20191009083202_create_dao_events.rb deleted file mode 100644 index 61c34ab17..000000000 --- a/db/migrate/20191009083202_create_dao_events.rb +++ /dev/null @@ -1,17 +0,0 @@ -class CreateDaoEvents < ActiveRecord::Migration[6.0] - def change - create_table :dao_events do |t| - t.bigint :block_id - t.bigint :ckb_transaction_id - t.bigint :address_id - t.bigint :contract_id - t.integer :event_type, limit: 1 - t.decimal :value, precision: 30, default: "0" - t.integer :status, limit: 1, default: "0" - - t.timestamps - end - - add_index :dao_events, :block_id - end -end diff --git a/db/migrate/20191108023656_rename_subsidy_to_interest.rb b/db/migrate/20191108023656_rename_subsidy_to_interest.rb deleted file mode 100644 index 4dcd854ae..000000000 --- a/db/migrate/20191108023656_rename_subsidy_to_interest.rb +++ /dev/null @@ -1,6 +0,0 @@ -class RenameSubsidyToInterest < ActiveRecord::Migration[6.0] - def change - rename_column :addresses, :subsidy, :interest - rename_column :dao_contracts, :subsidy_granted, :interest_granted - end -end diff --git a/db/migrate/20191108111509_add_data_size_to_cell_output.rb b/db/migrate/20191108111509_add_data_size_to_cell_output.rb deleted file mode 100644 index 916e2fe59..000000000 --- a/db/migrate/20191108111509_add_data_size_to_cell_output.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddDataSizeToCellOutput < ActiveRecord::Migration[6.0] - def change - add_column :cell_outputs, :data_size, :integer - end -end diff --git a/db/migrate/20191108122048_add_occupied_capacity_to_cell_outputs.rb b/db/migrate/20191108122048_add_occupied_capacity_to_cell_outputs.rb deleted file mode 100644 index 5f3868610..000000000 --- a/db/migrate/20191108122048_add_occupied_capacity_to_cell_outputs.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddOccupiedCapacityToCellOutputs < ActiveRecord::Migration[6.0] - def change - add_column :cell_outputs, :occupied_capacity, :decimal, precision: 30, scale: 0 - end -end diff --git a/db/migrate/20191126225038_add_timestamp_to_address_and_cell_outputs.rb b/db/migrate/20191126225038_add_timestamp_to_address_and_cell_outputs.rb deleted file mode 100644 index 730e3c70f..000000000 --- a/db/migrate/20191126225038_add_timestamp_to_address_and_cell_outputs.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddTimestampToAddressAndCellOutputs < ActiveRecord::Migration[6.0] - def change - add_column :addresses, :block_timestamp, :decimal, precision: 30, scale: 0 - add_column :cell_outputs, :block_timestamp, :decimal, precision: 30, scale: 0 - end -end diff --git a/db/migrate/20191127045149_create_daily_statistics.rb b/db/migrate/20191127045149_create_daily_statistics.rb deleted file mode 100644 index fcc99cecb..000000000 --- a/db/migrate/20191127045149_create_daily_statistics.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateDailyStatistics < ActiveRecord::Migration[6.0] - def change - create_table :daily_statistics do |t| - t.integer :transactions_count, default: 0 - t.integer :addresses_count, default: 0 - t.decimal :total_dao_deposit, precision: 30, default: 0 - t.decimal :block_timestamp, precision: 30 - t.integer :created_at_unixtimestamp - - t.timestamps - end - end -end diff --git a/db/migrate/20191201023327_create_block_statistics.rb b/db/migrate/20191201023327_create_block_statistics.rb deleted file mode 100644 index 8d8d24e49..000000000 --- a/db/migrate/20191201023327_create_block_statistics.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateBlockStatistics < ActiveRecord::Migration[6.0] - def change - create_table :block_statistics do |t| - t.string :difficulty - t.string :hash_rate - t.string :live_cell_count, default: "0" - t.string :dead_cell_count, default: "0" - t.string :block_number - - t.timestamps - end - end -end diff --git a/db/migrate/20191201111810_create_epoch_statistics.rb b/db/migrate/20191201111810_create_epoch_statistics.rb deleted file mode 100644 index 612b1a610..000000000 --- a/db/migrate/20191201111810_create_epoch_statistics.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateEpochStatistics < ActiveRecord::Migration[6.0] - def change - create_table :epoch_statistics do |t| - t.string :difficulty - t.string :uncle_rate - t.string :epoch_number - - t.timestamps - end - end -end diff --git a/db/migrate/20191202080732_change_integer_to_string_on_daily_statistics.rb b/db/migrate/20191202080732_change_integer_to_string_on_daily_statistics.rb deleted file mode 100644 index 628ed2f29..000000000 --- a/db/migrate/20191202080732_change_integer_to_string_on_daily_statistics.rb +++ /dev/null @@ -1,7 +0,0 @@ -class ChangeIntegerToStringOnDailyStatistics < ActiveRecord::Migration[6.0] - def change - change_column :daily_statistics, :transactions_count, :string - change_column :daily_statistics, :addresses_count, :string - change_column :daily_statistics, :total_dao_deposit, :string - end -end diff --git a/db/migrate/20191202081157_rename_cell_count_to_cells_count_on_block_statistics.rb b/db/migrate/20191202081157_rename_cell_count_to_cells_count_on_block_statistics.rb deleted file mode 100644 index 19bcebfc5..000000000 --- a/db/migrate/20191202081157_rename_cell_count_to_cells_count_on_block_statistics.rb +++ /dev/null @@ -1,6 +0,0 @@ -class RenameCellCountToCellsCountOnBlockStatistics < ActiveRecord::Migration[6.0] - def change - rename_column :block_statistics, :live_cell_count, :live_cells_count - rename_column :block_statistics, :dead_cell_count, :dead_cells_count - end -end diff --git a/db/migrate/20191205065410_add_live_cells_count_to_addresses.rb b/db/migrate/20191205065410_add_live_cells_count_to_addresses.rb deleted file mode 100644 index a43498aad..000000000 --- a/db/migrate/20191205065410_add_live_cells_count_to_addresses.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddLiveCellsCountToAddresses < ActiveRecord::Migration[6.0] - def change - add_column :addresses, :live_cells_count, :decimal, precision: 30, scale: 0, default: 0 - end -end diff --git a/db/migrate/20191206015942_add_mined_blocks_count_to_addresses.rb b/db/migrate/20191206015942_add_mined_blocks_count_to_addresses.rb deleted file mode 100644 index 436651277..000000000 --- a/db/migrate/20191206015942_add_mined_blocks_count_to_addresses.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddMinedBlocksCountToAddresses < ActiveRecord::Migration[6.0] - def change - add_column :addresses, :mined_blocks_count, :integer, default: 0 - end -end diff --git a/db/migrate/20191206042241_create_mining_infos.rb b/db/migrate/20191206042241_create_mining_infos.rb deleted file mode 100644 index 4aff9bafc..000000000 --- a/db/migrate/20191206042241_create_mining_infos.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateMiningInfos < ActiveRecord::Migration[6.0] - def change - create_table :mining_infos do |t| - t.bigint :address_id - t.bigint :block_id, index: true, unique: true - t.decimal :block_number, precision: 30, index: true - t.integer :status, limit: 1, default: "0" - - t.timestamps - end - end -end diff --git a/db/migrate/20191208071607_change_epoch_number_to_decimal.rb b/db/migrate/20191208071607_change_epoch_number_to_decimal.rb deleted file mode 100644 index edca6a04f..000000000 --- a/db/migrate/20191208071607_change_epoch_number_to_decimal.rb +++ /dev/null @@ -1,9 +0,0 @@ -class ChangeEpochNumberToDecimal < ActiveRecord::Migration[6.0] - def change - change_column :epoch_statistics, :epoch_number, :decimal, precision: 30, scale: 0, using: "epoch_number::numeric(30,0)" - change_column :block_statistics, :block_number, :decimal, precision: 30, scale: 0, using: "block_number::numeric(30,0)" - - add_index :epoch_statistics, :epoch_number, unique: true - add_index :block_statistics, :block_number, unique: true - end -end diff --git a/db/migrate/20191209054145_add_epoch_number_to_block_statistics.rb b/db/migrate/20191209054145_add_epoch_number_to_block_statistics.rb deleted file mode 100644 index 9324bd077..000000000 --- a/db/migrate/20191209054145_add_epoch_number_to_block_statistics.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddEpochNumberToBlockStatistics < ActiveRecord::Migration[6.0] - def change - add_column :block_statistics, :epoch_number, :decimal, precision: 30, scale: 0 - end -end diff --git a/db/migrate/20191213030520_add_visible_to_address.rb b/db/migrate/20191213030520_add_visible_to_address.rb deleted file mode 100644 index aae503139..000000000 --- a/db/migrate/20191213030520_add_visible_to_address.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddVisibleToAddress < ActiveRecord::Migration[6.0] - def change - add_column :addresses, :visible, :boolean, default: true - end -end diff --git a/db/migrate/20191216080206_remove_pending_reward_blocks_count_from_addresses.rb b/db/migrate/20191216080206_remove_pending_reward_blocks_count_from_addresses.rb deleted file mode 100644 index d79ceeaf8..000000000 --- a/db/migrate/20191216080206_remove_pending_reward_blocks_count_from_addresses.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RemovePendingRewardBlocksCountFromAddresses < ActiveRecord::Migration[6.0] - def change - remove_column :addresses, :pending_reward_blocks_count - end -end diff --git a/db/migrate/20191219014039_add_more_field_to_daily_statistics.rb b/db/migrate/20191219014039_add_more_field_to_daily_statistics.rb deleted file mode 100644 index 4a7ffd1ce..000000000 --- a/db/migrate/20191219014039_add_more_field_to_daily_statistics.rb +++ /dev/null @@ -1,12 +0,0 @@ -class AddMoreFieldToDailyStatistics < ActiveRecord::Migration[6.0] - def change - add_column :daily_statistics, :dao_depositors_count, :string, default: "0" - add_column :daily_statistics, :unclaimed_compensation, :string, default: "0" - add_column :daily_statistics, :claimed_compensation, :string, default: "0" - add_column :daily_statistics, :average_deposit_time, :string, default: "0" - add_column :daily_statistics, :estimated_apc, :string, default: "0" - add_column :daily_statistics, :mining_reward, :string, default: "0" - add_column :daily_statistics, :deposit_compensation, :string, default: "0" - add_column :daily_statistics, :treasury_amount, :string, default: "0" - end -end diff --git a/db/migrate/20191219020035_add_block_timestamp_to_dao_events.rb b/db/migrate/20191219020035_add_block_timestamp_to_dao_events.rb deleted file mode 100644 index 93a6ae036..000000000 --- a/db/migrate/20191219020035_add_block_timestamp_to_dao_events.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddBlockTimestampToDaoEvents < ActiveRecord::Migration[6.0] - def change - add_column :dao_events, :block_timestamp, :decimal, precision: 30, scale: 0 - end -end diff --git a/db/migrate/20191225110229_add_live_cell_changes_to_block_and_ckb_transaction.rb b/db/migrate/20191225110229_add_live_cell_changes_to_block_and_ckb_transaction.rb deleted file mode 100644 index 78c6c585d..000000000 --- a/db/migrate/20191225110229_add_live_cell_changes_to_block_and_ckb_transaction.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddLiveCellChangesToBlockAndCkbTransaction < ActiveRecord::Migration[6.0] - def change - add_column :blocks, :live_cell_changes, :integer - add_column :ckb_transactions, :live_cell_changes, :integer - end -end diff --git a/db/migrate/20191225131337_add_capacity_involved_to_ckb_transactions.rb b/db/migrate/20191225131337_add_capacity_involved_to_ckb_transactions.rb deleted file mode 100644 index 7cca9dc36..000000000 --- a/db/migrate/20191225131337_add_capacity_involved_to_ckb_transactions.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCapacityInvolvedToCkbTransactions < ActiveRecord::Migration[6.0] - def change - add_column :ckb_transactions, :capacity_involved, :decimal, precision: 30, scale: 0 - end -end diff --git a/db/migrate/20191225153746_add_live_cell_chagnes_to_forked_block.rb b/db/migrate/20191225153746_add_live_cell_chagnes_to_forked_block.rb deleted file mode 100644 index 0194aceea..000000000 --- a/db/migrate/20191225153746_add_live_cell_chagnes_to_forked_block.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddLiveCellChagnesToForkedBlock < ActiveRecord::Migration[6.0] - def change - add_column :forked_blocks, :live_cell_changes, :integer - end -end diff --git a/db/migrate/20191226084920_add_hash_rate_to_epoch_statistic.rb b/db/migrate/20191226084920_add_hash_rate_to_epoch_statistic.rb deleted file mode 100644 index 8a400beb1..000000000 --- a/db/migrate/20191226084920_add_hash_rate_to_epoch_statistic.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddHashRateToEpochStatistic < ActiveRecord::Migration[6.0] - def change - add_column :epoch_statistics, :hash_rate, :string - end -end diff --git a/db/migrate/20191230012431_create_forked_events.rb b/db/migrate/20191230012431_create_forked_events.rb deleted file mode 100644 index aaabf231f..000000000 --- a/db/migrate/20191230012431_create_forked_events.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateForkedEvents < ActiveRecord::Migration[6.0] - def change - create_table :forked_events do |t| - t.decimal :block_number, precision: 30 - t.decimal :epoch_number, precision: 30 - t.decimal :block_timestamp, precision: 30 - t.integer :status, limit: 1, default: 0, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20200103051008_add_consumed_block_timestamp_to_cell_outputs.rb b/db/migrate/20200103051008_add_consumed_block_timestamp_to_cell_outputs.rb deleted file mode 100644 index 758b2a97f..000000000 --- a/db/migrate/20200103051008_add_consumed_block_timestamp_to_cell_outputs.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddConsumedBlockTimestampToCellOutputs < ActiveRecord::Migration[6.0] - def change - add_column :cell_outputs, :consumed_block_timestamp, :decimal, precision: 30, scale: 0 - end -end diff --git a/db/migrate/20200110123617_add_index_to_block_timestamp_on_dao_events.rb b/db/migrate/20200110123617_add_index_to_block_timestamp_on_dao_events.rb deleted file mode 100644 index bfae71a1f..000000000 --- a/db/migrate/20200110123617_add_index_to_block_timestamp_on_dao_events.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddIndexToBlockTimestampOnDaoEvents < ActiveRecord::Migration[6.0] - def change - add_index :dao_events, :block_timestamp - add_index :dao_events, [:status, :event_type] - end -end diff --git a/db/migrate/20200115020206_add_new_columns_to_daily_statistic.rb b/db/migrate/20200115020206_add_new_columns_to_daily_statistic.rb deleted file mode 100644 index 2e709f5be..000000000 --- a/db/migrate/20200115020206_add_new_columns_to_daily_statistic.rb +++ /dev/null @@ -1,10 +0,0 @@ -class AddNewColumnsToDailyStatistic < ActiveRecord::Migration[6.0] - def change - add_column :daily_statistics, :live_cells_count, :string, default: "0" - add_column :daily_statistics, :dead_cells_count, :string, default: "0" - add_column :daily_statistics, :avg_hash_rate, :string, default: "0" - add_column :daily_statistics, :avg_difficulty, :string, default: "0" - add_column :daily_statistics, :uncle_rate, :string, default: "0" - add_column :daily_statistics, :total_depositors_count, :string, default: "0" - end -end diff --git a/db/migrate/20200121083529_add_claimed_and_unclaimed_compensation_to_dao_contract.rb b/db/migrate/20200121083529_add_claimed_and_unclaimed_compensation_to_dao_contract.rb deleted file mode 100644 index d7eef62ce..000000000 --- a/db/migrate/20200121083529_add_claimed_and_unclaimed_compensation_to_dao_contract.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddClaimedAndUnclaimedCompensationToDaoContract < ActiveRecord::Migration[6.0] - def change - rename_column :dao_contracts, :interest_granted, :claimed_compensation - add_column :dao_contracts, :unclaimed_compensation, :decimal, precision: 30, scale: 0 - end -end diff --git a/db/migrate/20200122060907_add_average_deposit_time_to_address.rb b/db/migrate/20200122060907_add_average_deposit_time_to_address.rb deleted file mode 100644 index ab12e192f..000000000 --- a/db/migrate/20200122060907_add_average_deposit_time_to_address.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddAverageDepositTimeToAddress < ActiveRecord::Migration[6.0] - def change - add_column :addresses, :average_deposit_time, :decimal - end -end diff --git a/db/migrate/20200226063458_create_udt_accounts.rb b/db/migrate/20200226063458_create_udt_accounts.rb deleted file mode 100644 index 94e7f4cb2..000000000 --- a/db/migrate/20200226063458_create_udt_accounts.rb +++ /dev/null @@ -1,19 +0,0 @@ -class CreateUdtAccounts < ActiveRecord::Migration[6.0] - def change - create_table :udt_accounts do |t| - t.integer :udt_type - t.string :full_name - t.string :symbol - t.integer :decimal - t.decimal :amount, precision: 40, default: 0 - t.boolean :published, default: false - t.binary :code_hash - t.string :type_hash - t.references :address - - t.timestamps - end - - add_index :udt_accounts, [:type_hash, :address_id], unique: true - end -end diff --git a/db/migrate/20200226072529_create_udts.rb b/db/migrate/20200226072529_create_udts.rb deleted file mode 100644 index 1a8a650c0..000000000 --- a/db/migrate/20200226072529_create_udts.rb +++ /dev/null @@ -1,24 +0,0 @@ -class CreateUdts < ActiveRecord::Migration[6.0] - def change - create_table :udts do |t| - t.binary :code_hash - t.string :hash_type - t.string :args - t.string :type_hash - t.string :full_name - t.string :symbol - t.integer :decimal - t.string :description - t.string :icon_file - t.string :operator_website - t.decimal :addresses_count, precision: 30, default: 0 - t.decimal :total_amount, precision: 40, default: 0 - t.integer :udt_type - t.boolean :published, default: false - - t.timestamps - end - - add_index :udts, :type_hash, unique: true - end -end diff --git a/db/migrate/20200302075922_add_type_hash_to_cell_output.rb b/db/migrate/20200302075922_add_type_hash_to_cell_output.rb deleted file mode 100644 index c27c0fca7..000000000 --- a/db/migrate/20200302075922_add_type_hash_to_cell_output.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddTypeHashToCellOutput < ActiveRecord::Migration[6.0] - def change - add_column :cell_outputs, :type_hash, :string - end -end diff --git a/db/migrate/20200305132554_add_udt_amount_to_cell_output.rb b/db/migrate/20200305132554_add_udt_amount_to_cell_output.rb deleted file mode 100644 index bddc222b4..000000000 --- a/db/migrate/20200305132554_add_udt_amount_to_cell_output.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddUdtAmountToCellOutput < ActiveRecord::Migration[6.0] - def change - add_column :cell_outputs, :udt_amount, :decimal, precision: 40, scale: 0 - end -end diff --git a/db/migrate/20200326050752_add_udt_reference_to_udt_account.rb b/db/migrate/20200326050752_add_udt_reference_to_udt_account.rb deleted file mode 100644 index d65decd75..000000000 --- a/db/migrate/20200326050752_add_udt_reference_to_udt_account.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddUdtReferenceToUdtAccount < ActiveRecord::Migration[6.0] - def change - add_belongs_to :udt_accounts, :udt, index: true - end -end diff --git a/db/migrate/20200409151035_add_total_tx_fee_to_daily_statistic.rb b/db/migrate/20200409151035_add_total_tx_fee_to_daily_statistic.rb deleted file mode 100644 index f76b6a037..000000000 --- a/db/migrate/20200409151035_add_total_tx_fee_to_daily_statistic.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddTotalTxFeeToDailyStatistic < ActiveRecord::Migration[6.0] - def change - add_column :daily_statistics, :total_tx_fee, :decimal, precision: 30, scale: 0 - end -end diff --git a/db/migrate/20200413030841_add_address_balance_distribution_to_daily_statistics.rb b/db/migrate/20200413030841_add_address_balance_distribution_to_daily_statistics.rb deleted file mode 100644 index 77cfad89e..000000000 --- a/db/migrate/20200413030841_add_address_balance_distribution_to_daily_statistics.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddAddressBalanceDistributionToDailyStatistics < ActiveRecord::Migration[6.0] - def change - add_column :daily_statistics, :address_balance_distribution, :jsonb - end -end diff --git a/db/migrate/20200414065915_add_block_time_distribution_to_epoch_statistic.rb b/db/migrate/20200414065915_add_block_time_distribution_to_epoch_statistic.rb deleted file mode 100644 index e40092227..000000000 --- a/db/migrate/20200414065915_add_block_time_distribution_to_epoch_statistic.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddBlockTimeDistributionToEpochStatistic < ActiveRecord::Migration[6.0] - def change - add_column :epoch_statistics, :block_time_distribution, :jsonb - end -end diff --git a/db/migrate/20200414082343_add_block_time_to_blocks.rb b/db/migrate/20200414082343_add_block_time_to_blocks.rb deleted file mode 100644 index cfae5fcf3..000000000 --- a/db/migrate/20200414082343_add_block_time_to_blocks.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddBlockTimeToBlocks < ActiveRecord::Migration[6.0] - def change - add_column :blocks, :block_time, :decimal, precision: 13 - add_column :forked_blocks, :block_time, :decimal, precision: 13 - end -end diff --git a/db/migrate/20200415022539_add_index_on_epoch_to_blocks.rb b/db/migrate/20200415022539_add_index_on_epoch_to_blocks.rb deleted file mode 100644 index 99cb8694e..000000000 --- a/db/migrate/20200415022539_add_index_on_epoch_to_blocks.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddIndexOnEpochToBlocks < ActiveRecord::Migration[6.0] - disable_ddl_transaction! - - def change - add_index :blocks, :epoch, algorithm: :concurrently - end -end diff --git a/db/migrate/20200416060532_add_occupied_capacity_to_daily_statistics.rb b/db/migrate/20200416060532_add_occupied_capacity_to_daily_statistics.rb deleted file mode 100644 index 17fc936a7..000000000 --- a/db/migrate/20200416060532_add_occupied_capacity_to_daily_statistics.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddOccupiedCapacityToDailyStatistics < ActiveRecord::Migration[6.0] - def change - add_column :daily_statistics, :occupied_capacity, :decimal, precision: 30 - end -end diff --git a/db/migrate/20200416090920_add_epoch_time_to_epoch_statistics.rb b/db/migrate/20200416090920_add_epoch_time_to_epoch_statistics.rb deleted file mode 100644 index b474fafcf..000000000 --- a/db/migrate/20200416090920_add_epoch_time_to_epoch_statistics.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddEpochTimeToEpochStatistics < ActiveRecord::Migration[6.0] - def change - add_column :epoch_statistics, :epoch_time, :decimal, precision: 13 - end -end diff --git a/db/migrate/20200417020812_add_epoch_time_distribution_to_epoch_statistics.rb b/db/migrate/20200417020812_add_epoch_time_distribution_to_epoch_statistics.rb deleted file mode 100644 index 1278ec464..000000000 --- a/db/migrate/20200417020812_add_epoch_time_distribution_to_epoch_statistics.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddEpochTimeDistributionToEpochStatistics < ActiveRecord::Migration[6.0] - def change - add_column :epoch_statistics, :epoch_time_distribution, :jsonb - end -end diff --git a/db/migrate/20200417092543_add_epoch_length_to_epoch_statistics.rb b/db/migrate/20200417092543_add_epoch_length_to_epoch_statistics.rb deleted file mode 100644 index ee061f452..000000000 --- a/db/migrate/20200417092543_add_epoch_length_to_epoch_statistics.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddEpochLengthToEpochStatistics < ActiveRecord::Migration[6.0] - def change - add_column :epoch_statistics, :epoch_length, :integer - end -end diff --git a/db/migrate/20200417095215_add_epoch_length_distribution_to_epoch_statistics.rb b/db/migrate/20200417095215_add_epoch_length_distribution_to_epoch_statistics.rb deleted file mode 100644 index 1adbfdd5e..000000000 --- a/db/migrate/20200417095215_add_epoch_length_distribution_to_epoch_statistics.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddEpochLengthDistributionToEpochStatistics < ActiveRecord::Migration[6.0] - def change - add_column :epoch_statistics, :epoch_length_distribution, :json - end -end diff --git a/db/migrate/20200421013646_add_block_size_to_block.rb b/db/migrate/20200421013646_add_block_size_to_block.rb deleted file mode 100644 index 8d3d95e77..000000000 --- a/db/migrate/20200421013646_add_block_size_to_block.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddBlockSizeToBlock < ActiveRecord::Migration[6.0] - def change - add_column :blocks, :block_size, :integer - add_column :forked_blocks, :block_size, :integer - end -end diff --git a/db/migrate/20200423031220_add_index_to_block_size_on_block.rb b/db/migrate/20200423031220_add_index_to_block_size_on_block.rb deleted file mode 100644 index 9da27b5c8..000000000 --- a/db/migrate/20200423031220_add_index_to_block_size_on_block.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddIndexToBlockSizeOnBlock < ActiveRecord::Migration[6.0] - disable_ddl_transaction! - - def change - add_index :blocks, :block_size, algorithm: :concurrently - add_index :blocks, :block_time, algorithm: :concurrently - end -end diff --git a/db/migrate/20200424084519_add_daily_dao_deposit_to_daily_statistics.rb b/db/migrate/20200424084519_add_daily_dao_deposit_to_daily_statistics.rb deleted file mode 100644 index 1074d11c8..000000000 --- a/db/migrate/20200424084519_add_daily_dao_deposit_to_daily_statistics.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddDailyDaoDepositToDailyStatistics < ActiveRecord::Migration[6.0] - def change - add_column :daily_statistics, :daily_dao_deposit, :decimal, precision: 30 - add_column :daily_statistics, :daily_dao_depositors_count, :integer - add_column :daily_statistics, :daily_dao_withdraw, :decimal, precision: 30 - end -end diff --git a/db/migrate/20200427041823_add_circulation_ratio_to_daily_statistic.rb b/db/migrate/20200427041823_add_circulation_ratio_to_daily_statistic.rb deleted file mode 100644 index 712fc1b9a..000000000 --- a/db/migrate/20200427041823_add_circulation_ratio_to_daily_statistic.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCirculationRatioToDailyStatistic < ActiveRecord::Migration[6.0] - def change - add_column :daily_statistics, :circulation_ratio, :decimal - end -end diff --git a/db/migrate/20200427073824_add_total_supply_to_daily_statistic.rb b/db/migrate/20200427073824_add_total_supply_to_daily_statistic.rb deleted file mode 100644 index 3e8cffeec..000000000 --- a/db/migrate/20200427073824_add_total_supply_to_daily_statistic.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddTotalSupplyToDailyStatistic < ActiveRecord::Migration[6.0] - def change - add_column :daily_statistics, :total_supply, :decimal, precision: 30 - end -end diff --git a/db/migrate/20200427101449_add_circulating_supply_to_daily_statistic.rb b/db/migrate/20200427101449_add_circulating_supply_to_daily_statistic.rb deleted file mode 100644 index 24047b72a..000000000 --- a/db/migrate/20200427101449_add_circulating_supply_to_daily_statistic.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCirculatingSupplyToDailyStatistic < ActiveRecord::Migration[6.0] - def change - add_column :daily_statistics, :circulating_supply, :decimal - end -end diff --git a/db/migrate/20200428070217_move_block_time_distribution_from_epoch_to_daily.rb b/db/migrate/20200428070217_move_block_time_distribution_from_epoch_to_daily.rb deleted file mode 100644 index 093bc5475..000000000 --- a/db/migrate/20200428070217_move_block_time_distribution_from_epoch_to_daily.rb +++ /dev/null @@ -1,6 +0,0 @@ -class MoveBlockTimeDistributionFromEpochToDaily < ActiveRecord::Migration[6.0] - def change - remove_column :epoch_statistics, :block_time_distribution - add_column :daily_statistics, :block_time_distribution, :jsonb - end -end diff --git a/db/migrate/20200428092757_move_distribution_info_to_daily_statistic.rb b/db/migrate/20200428092757_move_distribution_info_to_daily_statistic.rb deleted file mode 100644 index 4fd43e433..000000000 --- a/db/migrate/20200428092757_move_distribution_info_to_daily_statistic.rb +++ /dev/null @@ -1,8 +0,0 @@ -class MoveDistributionInfoToDailyStatistic < ActiveRecord::Migration[6.0] - def change - remove_column :epoch_statistics, :epoch_time_distribution - remove_column :epoch_statistics, :epoch_length_distribution - add_column :daily_statistics, :epoch_time_distribution, :jsonb - add_column :daily_statistics, :epoch_length_distribution, :jsonb - end -end diff --git a/db/migrate/20200430110951_create_block_time_statistics.rb b/db/migrate/20200430110951_create_block_time_statistics.rb deleted file mode 100644 index 9c68877a8..000000000 --- a/db/migrate/20200430110951_create_block_time_statistics.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateBlockTimeStatistics < ActiveRecord::Migration[6.0] - def change - create_table :block_time_statistics do |t| - t.decimal :stat_timestamp, precision: 30 - t.decimal :avg_block_time_per_hour - - t.timestamps - end - - add_index :block_time_statistics, :stat_timestamp, unique: true - end -end diff --git a/db/migrate/20200430124336_add_average_block_time_to_daily_statistics.rb b/db/migrate/20200430124336_add_average_block_time_to_daily_statistics.rb deleted file mode 100644 index d3abdd533..000000000 --- a/db/migrate/20200430124336_add_average_block_time_to_daily_statistics.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddAverageBlockTimeToDailyStatistics < ActiveRecord::Migration[6.0] - def change - add_column :daily_statistics, :average_block_time, :jsonb - end -end diff --git a/db/migrate/20200506043401_add_nodes_distribution_to_daily_statistics.rb b/db/migrate/20200506043401_add_nodes_distribution_to_daily_statistics.rb deleted file mode 100644 index a4b2bf8b0..000000000 --- a/db/migrate/20200506043401_add_nodes_distribution_to_daily_statistics.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddNodesDistributionToDailyStatistics < ActiveRecord::Migration[6.0] - def change - add_column :daily_statistics, :nodes_distribution, :jsonb - add_column :daily_statistics, :nodes_count, :integer - end -end diff --git a/db/migrate/20200509144539_create_block_propagation_delays.rb b/db/migrate/20200509144539_create_block_propagation_delays.rb deleted file mode 100644 index 14e91b534..000000000 --- a/db/migrate/20200509144539_create_block_propagation_delays.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateBlockPropagationDelays < ActiveRecord::Migration[6.0] - def change - create_table :block_propagation_delays do |t| - t.string :block_hash - t.integer :created_at_unixtimestamp, index: true - t.jsonb :durations - - t.timestamps - end - end -end diff --git a/db/migrate/20200513032346_create_transaction_propagation_delays.rb b/db/migrate/20200513032346_create_transaction_propagation_delays.rb deleted file mode 100644 index 649f5cd8f..000000000 --- a/db/migrate/20200513032346_create_transaction_propagation_delays.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateTransactionPropagationDelays < ActiveRecord::Migration[6.0] - def change - create_table :transaction_propagation_delays do |t| - t.string :tx_hash - t.integer :created_at_unixtimestamp - t.jsonb :durations - - t.timestamps - end - - add_index :transaction_propagation_delays, :created_at_unixtimestamp, name: "index_tx_propagation_timestamp" - end -end diff --git a/db/migrate/20200525100826_add_locked_capacity_to_daily_statistic.rb b/db/migrate/20200525100826_add_locked_capacity_to_daily_statistic.rb deleted file mode 100644 index 0b29b1c9b..000000000 --- a/db/migrate/20200525100826_add_locked_capacity_to_daily_statistic.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddLockedCapacityToDailyStatistic < ActiveRecord::Migration[6.0] - def change - add_column :daily_statistics, :locked_capacity, :decimal, precision: 30 - end -end diff --git a/db/migrate/20200601121842_add_block_timestamp_to_udts.rb b/db/migrate/20200601121842_add_block_timestamp_to_udts.rb deleted file mode 100644 index a9d0eaf88..000000000 --- a/db/migrate/20200601121842_add_block_timestamp_to_udts.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddBlockTimestampToUdts < ActiveRecord::Migration[6.0] - def change - add_column :udts, :block_timestamp, :decimal, precision: 30 - end -end diff --git a/db/migrate/20200618102442_add_issuer_address_to_udts.rb b/db/migrate/20200618102442_add_issuer_address_to_udts.rb deleted file mode 100644 index 7401cc224..000000000 --- a/db/migrate/20200618102442_add_issuer_address_to_udts.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIssuerAddressToUdts < ActiveRecord::Migration[6.0] - def change - add_column :udts, :issuer_address, :binary - end -end diff --git a/db/migrate/20200624022548_add_proposal_and_commit_reward_to_blocks.rb b/db/migrate/20200624022548_add_proposal_and_commit_reward_to_blocks.rb deleted file mode 100644 index 7b999e05c..000000000 --- a/db/migrate/20200624022548_add_proposal_and_commit_reward_to_blocks.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddProposalAndCommitRewardToBlocks < ActiveRecord::Migration[6.0] - def change - add_column :blocks, :proposal_reward, :decimal, precision: 30 - add_column :blocks, :commit_reward, :decimal, precision: 30 - add_column :forked_blocks, :proposal_reward, :decimal, precision: 30 - add_column :forked_blocks, :commit_reward, :decimal, precision: 30 - end -end diff --git a/db/migrate/20200628091022_add_descending_index_on_timestamp_to_blocks.rb b/db/migrate/20200628091022_add_descending_index_on_timestamp_to_blocks.rb deleted file mode 100644 index 9ec0cd2c8..000000000 --- a/db/migrate/20200628091022_add_descending_index_on_timestamp_to_blocks.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddDescendingIndexOnTimestampToBlocks < ActiveRecord::Migration[6.0] - disable_ddl_transaction! - def change - remove_index :blocks, name: "index_blocks_on_timestamp", column: :timestamp, algorithm: :concurrently if index_exists?(:blocks, :timestamp) - add_index :blocks, :timestamp, order: { timestamp: "DESC NULLS LAST" }, algorithm: :concurrently - end -end diff --git a/db/migrate/20200702035301_add_unclaimed_compensation_to_address.rb b/db/migrate/20200702035301_add_unclaimed_compensation_to_address.rb deleted file mode 100644 index 7525f1ad8..000000000 --- a/db/migrate/20200702035301_add_unclaimed_compensation_to_address.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddUnclaimedCompensationToAddress < ActiveRecord::Migration[6.0] - def change - add_column :addresses, :unclaimed_compensation, :decimal, precision: 30 - end -end diff --git a/db/migrate/20200703043629_add_is_depositor_to_addresses.rb b/db/migrate/20200703043629_add_is_depositor_to_addresses.rb deleted file mode 100644 index e3f4fad68..000000000 --- a/db/migrate/20200703043629_add_is_depositor_to_addresses.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddIsDepositorToAddresses < ActiveRecord::Migration[6.0] - def change - add_column :addresses, :is_depositor, :boolean, default: false - add_index :addresses, :is_depositor, where: "is_depositor = true" - end -end diff --git a/db/migrate/20200709100457_add_descending_index_on_block_timestamp_to_ckb_transactions.rb b/db/migrate/20200709100457_add_descending_index_on_block_timestamp_to_ckb_transactions.rb deleted file mode 100644 index 86a062b9f..000000000 --- a/db/migrate/20200709100457_add_descending_index_on_block_timestamp_to_ckb_transactions.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddDescendingIndexOnBlockTimestampToCkbTransactions < ActiveRecord::Migration[6.0] - disable_ddl_transaction! - - def change - add_index :ckb_transactions, :block_timestamp, order: { block_timestamp: "DESC NULLS LAST" }, algorithm: :concurrently - end -end diff --git a/db/migrate/20200714044614_add_dao_cell_outputs.rb b/db/migrate/20200714044614_add_dao_cell_outputs.rb deleted file mode 100644 index 855afc157..000000000 --- a/db/migrate/20200714044614_add_dao_cell_outputs.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddDaoCellOutputs < ActiveRecord::Migration[6.0] - def change - add_column :cell_outputs, :dao, :string - end -end diff --git a/db/migrate/20200716174806_add_tags_address_ids_and_udt_type_hashes_to_ckb_transaction.rb b/db/migrate/20200716174806_add_tags_address_ids_and_udt_type_hashes_to_ckb_transaction.rb deleted file mode 100644 index 4d71912ec..000000000 --- a/db/migrate/20200716174806_add_tags_address_ids_and_udt_type_hashes_to_ckb_transaction.rb +++ /dev/null @@ -1,13 +0,0 @@ -class AddTagsAddressIdsAndUdtTypeHashesToCkbTransaction < ActiveRecord::Migration[6.0] - disable_ddl_transaction! - - def change - add_column :ckb_transactions, :contained_address_ids, :bigint, array: true, default: [] - add_column :ckb_transactions, :tags, :string, array: true, default: [] - add_column :ckb_transactions, :contained_udt_ids, :bigint, array: true, default: [] - - add_index :ckb_transactions, :contained_address_ids, using: :gin, algorithm: :concurrently - add_index :ckb_transactions, :tags, using: :gin, algorithm: :concurrently - add_index :ckb_transactions, :contained_udt_ids, using: :gin, algorithm: :concurrently - end -end diff --git a/db/migrate/20200729174146_adjust_block_timestamp_index.rb b/db/migrate/20200729174146_adjust_block_timestamp_index.rb deleted file mode 100644 index 1847f3f06..000000000 --- a/db/migrate/20200729174146_adjust_block_timestamp_index.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AdjustBlockTimestampIndex < ActiveRecord::Migration[6.0] - disable_ddl_transaction! - def change - remove_index :ckb_transactions, name: :index_ckb_transactions_on_block_timestamp, column: :block_timestamp, algorithm: :concurrently if index_exists?(:ckb_transactions, :block_timestamp) - add_index :ckb_transactions, [:block_timestamp, :id], order: { block_timestamp: "DESC NULLS LAST", id: "desc" }, algorithm: :concurrently - end -end diff --git a/db/migrate/20200803152507_create_table_record_counts.rb b/db/migrate/20200803152507_create_table_record_counts.rb deleted file mode 100644 index f344d9a0d..000000000 --- a/db/migrate/20200803152507_create_table_record_counts.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateTableRecordCounts < ActiveRecord::Migration[6.0] - def change - create_table :table_record_counts do |t| - t.string :table_name - t.bigint :count - - t.timestamps - end - - add_index :table_record_counts, [:table_name, :count] - end -end diff --git a/db/migrate/20200805093044_add_ckb_transactions_count_to_udts.rb b/db/migrate/20200805093044_add_ckb_transactions_count_to_udts.rb deleted file mode 100644 index 896ed8d72..000000000 --- a/db/migrate/20200805093044_add_ckb_transactions_count_to_udts.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCkbTransactionsCountToUdts < ActiveRecord::Migration[6.0] - def change - add_column :udts, :ckb_transactions_count, :decimal, precision: 30, default: 0 - end -end diff --git a/db/migrate/20200806060029_add_ckb_transactions_count_to_dao_contracts.rb b/db/migrate/20200806060029_add_ckb_transactions_count_to_dao_contracts.rb deleted file mode 100644 index 2938948f6..000000000 --- a/db/migrate/20200806060029_add_ckb_transactions_count_to_dao_contracts.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCkbTransactionsCountToDaoContracts < ActiveRecord::Migration[6.0] - def change - add_column :dao_contracts, :ckb_transactions_count, :decimal, precision: 30, default: 0 - end -end diff --git a/db/migrate/20200806071500_add_dao_ckb_transactions_count_to_addresses.rb b/db/migrate/20200806071500_add_dao_ckb_transactions_count_to_addresses.rb deleted file mode 100644 index 22ce6d923..000000000 --- a/db/migrate/20200806071500_add_dao_ckb_transactions_count_to_addresses.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddDaoCkbTransactionsCountToAddresses < ActiveRecord::Migration[6.0] - def change - add_column :addresses, :dao_transactions_count, :decimal, precision: 30, default: 0 - end -end diff --git a/db/migrate/20200806081043_add_dao_address_ids_to_ckb_transactions.rb b/db/migrate/20200806081043_add_dao_address_ids_to_ckb_transactions.rb deleted file mode 100644 index cbb71a56f..000000000 --- a/db/migrate/20200806081043_add_dao_address_ids_to_ckb_transactions.rb +++ /dev/null @@ -1,11 +0,0 @@ -class AddDaoAddressIdsToCkbTransactions < ActiveRecord::Migration[6.0] - disable_ddl_transaction! - - def change - add_column :ckb_transactions, :dao_address_ids, :bigint, array: true, default: [] - add_column :ckb_transactions, :udt_address_ids, :bigint, array: true, default: [] - - add_index :ckb_transactions, :dao_address_ids, using: :gin, algorithm: :concurrently - add_index :ckb_transactions, :udt_address_ids, using: :gin, algorithm: :concurrently - end -end diff --git a/db/migrate/20201029140549_create_pool_transaction_entries.rb b/db/migrate/20201029140549_create_pool_transaction_entries.rb deleted file mode 100644 index d8e027b83..000000000 --- a/db/migrate/20201029140549_create_pool_transaction_entries.rb +++ /dev/null @@ -1,26 +0,0 @@ -class CreatePoolTransactionEntries < ActiveRecord::Migration[6.0] - def change - create_table :pool_transaction_entries do |t| - t.jsonb :cell_deps - t.binary :tx_hash - t.jsonb :header_deps - t.jsonb :inputs - t.jsonb :outputs - t.jsonb :outputs_data - t.integer :version - t.jsonb :witnesses - t.decimal :transaction_fee, precision: 30, scale: 0 - t.decimal :block_number, precision: 30, scale: 0 - t.decimal :block_timestamp, precision: 30, scale: 0 - t.decimal :cycles, precision: 30, scale: 0 - t.decimal :tx_size, precision: 30, scale: 0 - t.jsonb :display_inputs - t.jsonb :display_outputs - t.integer :tx_status, default: 0 - - t.timestamps - end - - add_index :pool_transaction_entries, :tx_hash, unique: true - end -end diff --git a/db/migrate/20201218065319_add_index_on_created_at_unixtimestamp_to_daily_statistics.rb b/db/migrate/20201218065319_add_index_on_created_at_unixtimestamp_to_daily_statistics.rb deleted file mode 100644 index 17fb782a3..000000000 --- a/db/migrate/20201218065319_add_index_on_created_at_unixtimestamp_to_daily_statistics.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIndexOnCreatedAtUnixtimestampToDailyStatistics < ActiveRecord::Migration[6.0] - def change - add_index :daily_statistics, :created_at_unixtimestamp, order: { created_at_unixtimestamp: "DESC NULLS LAST" } - end -end diff --git a/db/migrate/20201224071647_create_tx_display_infos.rb b/db/migrate/20201224071647_create_tx_display_infos.rb deleted file mode 100644 index 8d768b8c5..000000000 --- a/db/migrate/20201224071647_create_tx_display_infos.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateTxDisplayInfos < ActiveRecord::Migration[6.0] - def change - create_table :tx_display_infos, id: false do |t| - t.bigint :ckb_transaction_id, primary_key: true, default: nil - t.jsonb :inputs - t.jsonb :outputs - - t.timestamps - end - end -end diff --git a/db/migrate/20201228095436_add_income_to_tx_display_infos.rb b/db/migrate/20201228095436_add_income_to_tx_display_infos.rb deleted file mode 100644 index 8d4fa668b..000000000 --- a/db/migrate/20201228095436_add_income_to_tx_display_infos.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIncomeToTxDisplayInfos < ActiveRecord::Migration[6.0] - def change - add_column :tx_display_infos, :income, :jsonb - end -end diff --git a/db/migrate/20210129123835_add_lock_script_id_and_type_script_id_to_cell_outputs.rb b/db/migrate/20210129123835_add_lock_script_id_and_type_script_id_to_cell_outputs.rb deleted file mode 100644 index a6c56c847..000000000 --- a/db/migrate/20210129123835_add_lock_script_id_and_type_script_id_to_cell_outputs.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddLockScriptIdAndTypeScriptIdToCellOutputs < ActiveRecord::Migration[6.0] - def change - add_column :cell_outputs, :lock_script_id, :bigint - add_column :cell_outputs, :type_script_id, :bigint - end -end diff --git a/db/migrate/20210129124809_add_cell_type_to_cell_inputs.rb b/db/migrate/20210129124809_add_cell_type_to_cell_inputs.rb deleted file mode 100644 index 67f622bff..000000000 --- a/db/migrate/20210129124809_add_cell_type_to_cell_inputs.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCellTypeToCellInputs < ActiveRecord::Migration[6.0] - def change - add_column :cell_inputs, :cell_type, :integer, default: 0 - end -end diff --git a/db/migrate/20210131120306_add_lock_hash_to_lock_scripts.rb b/db/migrate/20210131120306_add_lock_hash_to_lock_scripts.rb deleted file mode 100644 index 3303c7a2f..000000000 --- a/db/migrate/20210131120306_add_lock_hash_to_lock_scripts.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddLockHashToLockScripts < ActiveRecord::Migration[6.0] - def change - add_column :lock_scripts, :lock_hash, :string - add_column :type_scripts, :lock_hash, :string - end -end diff --git a/db/migrate/20210222102120_add_lock_script_id_to_address.rb b/db/migrate/20210222102120_add_lock_script_id_to_address.rb deleted file mode 100644 index 5ce28177f..000000000 --- a/db/migrate/20210222102120_add_lock_script_id_to_address.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddLockScriptIdToAddress < ActiveRecord::Migration[6.0] - def change - add_column :addresses, :lock_script_id, :bigint - end -end diff --git a/db/migrate/20210225124705_remove_deps_from_ckb_transactions.rb b/db/migrate/20210225124705_remove_deps_from_ckb_transactions.rb deleted file mode 100644 index 1665f5042..000000000 --- a/db/migrate/20210225124705_remove_deps_from_ckb_transactions.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RemoveDepsFromCkbTransactions < ActiveRecord::Migration[6.0] - def change - remove_column :ckb_transactions, :deps - end -end diff --git a/db/migrate/20210303023806_change_lock_hash_to_script_hash_on_scripts.rb b/db/migrate/20210303023806_change_lock_hash_to_script_hash_on_scripts.rb deleted file mode 100644 index b37eb236a..000000000 --- a/db/migrate/20210303023806_change_lock_hash_to_script_hash_on_scripts.rb +++ /dev/null @@ -1,6 +0,0 @@ -class ChangeLockHashToScriptHashOnScripts < ActiveRecord::Migration[6.0] - def change - rename_column :lock_scripts, :lock_hash, :script_hash - rename_column :type_scripts, :lock_hash, :script_hash - end -end diff --git a/db/migrate/20210304115516_add_index_on_scripts.rb b/db/migrate/20210304115516_add_index_on_scripts.rb deleted file mode 100644 index d5e95fe77..000000000 --- a/db/migrate/20210304115516_add_index_on_scripts.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddIndexOnScripts < ActiveRecord::Migration[6.0] - def change - add_index :lock_scripts, :script_hash - add_index :type_scripts, :script_hash - end -end diff --git a/db/migrate/20210509040821_add_index_on_type_and_locks.rb b/db/migrate/20210509040821_add_index_on_type_and_locks.rb deleted file mode 100644 index a2589db22..000000000 --- a/db/migrate/20210509040821_add_index_on_type_and_locks.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddIndexOnTypeAndLocks < ActiveRecord::Migration[6.0] - disable_ddl_transaction! - - def change - add_index :lock_scripts, [:code_hash, :hash_type, :args], algorithm: :concurrently - add_index :type_scripts, [:code_hash, :hash_type, :args], algorithm: :concurrently - end -end diff --git a/db/migrate/20210716052833_add_separate_index_on_status_to_cell_outputs.rb b/db/migrate/20210716052833_add_separate_index_on_status_to_cell_outputs.rb deleted file mode 100644 index a00546e82..000000000 --- a/db/migrate/20210716052833_add_separate_index_on_status_to_cell_outputs.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddSeparateIndexOnStatusToCellOutputs < ActiveRecord::Migration[6.0] - disable_ddl_transaction! - - def change - add_index :cell_outputs, :status, algorithm: :concurrently - end -end diff --git a/db/migrate/20210716053144_add_index_on_tx_status_to_pool_transaction_entries.rb b/db/migrate/20210716053144_add_index_on_tx_status_to_pool_transaction_entries.rb deleted file mode 100644 index fea398746..000000000 --- a/db/migrate/20210716053144_add_index_on_tx_status_to_pool_transaction_entries.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddIndexOnTxStatusToPoolTransactionEntries < ActiveRecord::Migration[6.0] - disable_ddl_transaction! - - def change - add_index :pool_transaction_entries, :tx_status, algorithm: :concurrently - end -end diff --git a/db/migrate/20210810022442_add_index_to_script_id_on_cell_outputs.rb b/db/migrate/20210810022442_add_index_to_script_id_on_cell_outputs.rb deleted file mode 100644 index 130fc3adf..000000000 --- a/db/migrate/20210810022442_add_index_to_script_id_on_cell_outputs.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddIndexToScriptIdOnCellOutputs < ActiveRecord::Migration[6.0] - disable_ddl_transaction! - def change - add_index :cell_outputs, :lock_script_id, algorithm: :concurrently - add_index :cell_outputs, :type_script_id, algorithm: :concurrently - end -end diff --git a/db/migrate/20210813081152_change_consumed_block_timestamp_default_value_to_zero.rb b/db/migrate/20210813081152_change_consumed_block_timestamp_default_value_to_zero.rb deleted file mode 100644 index cd7e1ac02..000000000 --- a/db/migrate/20210813081152_change_consumed_block_timestamp_default_value_to_zero.rb +++ /dev/null @@ -1,9 +0,0 @@ -class ChangeConsumedBlockTimestampDefaultValueToZero < ActiveRecord::Migration[6.0] - disable_ddl_transaction! - - def change - change_column_default :cell_outputs, :consumed_block_timestamp, from: nil, to: 0 - add_index :cell_outputs, :block_timestamp, if_not_exists: true, algorithm: :concurrently - add_index :cell_outputs, :consumed_block_timestamp, if_not_exists: true, algorithm: :concurrently - end -end diff --git a/db/migrate/20210819124921_change_address_balance_default_value_to_zero.rb b/db/migrate/20210819124921_change_address_balance_default_value_to_zero.rb deleted file mode 100644 index 65910f022..000000000 --- a/db/migrate/20210819124921_change_address_balance_default_value_to_zero.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ChangeAddressBalanceDefaultValueToZero < ActiveRecord::Migration[6.1] - def change - change_column_default :addresses, :balance, 0 - end -end diff --git a/db/migrate/20210824133215_add_miner_message_to_block.rb b/db/migrate/20210824133215_add_miner_message_to_block.rb deleted file mode 100644 index 1065f5fc6..000000000 --- a/db/migrate/20210824133215_add_miner_message_to_block.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddMinerMessageToBlock < ActiveRecord::Migration[6.1] - def change - add_column :blocks, :miner_message, :string - end -end diff --git a/db/migrate/20210824155634_add_miner_message_to_forked_block.rb b/db/migrate/20210824155634_add_miner_message_to_forked_block.rb deleted file mode 100644 index c6f85d83f..000000000 --- a/db/migrate/20210824155634_add_miner_message_to_forked_block.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddMinerMessageToForkedBlock < ActiveRecord::Migration[6.1] - def change - add_column :forked_blocks, :miner_message, :string - end -end diff --git a/db/migrate/20211015090450_add_extension_to_blocks.rb b/db/migrate/20211015090450_add_extension_to_blocks.rb deleted file mode 100644 index b0d5087ab..000000000 --- a/db/migrate/20211015090450_add_extension_to_blocks.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddExtensionToBlocks < ActiveRecord::Migration[6.1] - def change - add_column :blocks, :extension, :jsonb - add_column :forked_blocks, :extension, :jsonb - end -end diff --git a/db/migrate/20211015105234_rename_uncles_hash_to_extra_hash.rb b/db/migrate/20211015105234_rename_uncles_hash_to_extra_hash.rb deleted file mode 100644 index 9057accc7..000000000 --- a/db/migrate/20211015105234_rename_uncles_hash_to_extra_hash.rb +++ /dev/null @@ -1,7 +0,0 @@ -class RenameUnclesHashToExtraHash < ActiveRecord::Migration[6.1] - def change - rename_column :blocks, :uncles_hash, :extra_hash - rename_column :forked_blocks, :uncles_hash, :extra_hash - rename_column :uncle_blocks, :uncles_hash, :extra_hash - end -end diff --git a/db/migrate/20211103012805_add_balance_occupied_to_address.rb b/db/migrate/20211103012805_add_balance_occupied_to_address.rb deleted file mode 100644 index 2ecf5c0d8..000000000 --- a/db/migrate/20211103012805_add_balance_occupied_to_address.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddBalanceOccupiedToAddress < ActiveRecord::Migration[6.1] - def change - add_column :addresses, :balance_occupied, :decimal, precision: 30, default: 0 - end -end diff --git a/db/migrate/20211223141618_remove_index_from_address_hash.rb b/db/migrate/20211223141618_remove_index_from_address_hash.rb deleted file mode 100644 index 8b5527200..000000000 --- a/db/migrate/20211223141618_remove_index_from_address_hash.rb +++ /dev/null @@ -1,6 +0,0 @@ -class RemoveIndexFromAddressHash < ActiveRecord::Migration[6.1] - disable_ddl_transaction! - def change - remove_index :addresses, :address_hash, algorithm: :concurrently - end -end diff --git a/db/migrate/20211223141845_add_address_hash_crc_to_addresses.rb b/db/migrate/20211223141845_add_address_hash_crc_to_addresses.rb deleted file mode 100644 index 31a14e35b..000000000 --- a/db/migrate/20211223141845_add_address_hash_crc_to_addresses.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddAddressHashCrcToAddresses < ActiveRecord::Migration[6.1] - def change - add_column :addresses, :address_hash_crc, :bigint - add_index :addresses, :address_hash_crc - end -end diff --git a/db/migrate/20220216063204_add_nft_token_id_to_udt_account.rb b/db/migrate/20220216063204_add_nft_token_id_to_udt_account.rb deleted file mode 100644 index d0cced14b..000000000 --- a/db/migrate/20220216063204_add_nft_token_id_to_udt_account.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddNFTTokenIdToUdtAccount < ActiveRecord::Migration[6.1] - def change - add_column :udt_accounts, :nft_token_id, :string - end -end diff --git a/db/migrate/20220311140723_create_nrc_factory_cell.rb b/db/migrate/20220311140723_create_nrc_factory_cell.rb deleted file mode 100644 index 6b5275607..000000000 --- a/db/migrate/20220311140723_create_nrc_factory_cell.rb +++ /dev/null @@ -1,18 +0,0 @@ -class CreateNrcFactoryCell < ActiveRecord::Migration[6.1] - def change - create_table :nrc_factory_cells do |t| - t.binary :code_hash - t.string :hash_type - t.string :args - t.string :name - t.string :symbol - t.string :base_token_uri - t.string :extra_data - t.boolean :verified, default: false - - t.timestamps - end - - add_index :nrc_factory_cells, [:code_hash, :hash_type, :args], unique: true - end -end diff --git a/db/migrate/20220311144809_add_nrc_factory_cell_id_to_udts.rb b/db/migrate/20220311144809_add_nrc_factory_cell_id_to_udts.rb deleted file mode 100644 index 60081a172..000000000 --- a/db/migrate/20220311144809_add_nrc_factory_cell_id_to_udts.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddNrcFactoryCellIdToUdts < ActiveRecord::Migration[6.1] - def change - add_column :udts, :nrc_factory_cell_id, :bigint - end -end diff --git a/db/migrate/20220629011100_create_token_collections.rb b/db/migrate/20220629011100_create_token_collections.rb deleted file mode 100644 index f6875e6d8..000000000 --- a/db/migrate/20220629011100_create_token_collections.rb +++ /dev/null @@ -1,15 +0,0 @@ -class CreateTokenCollections < ActiveRecord::Migration[6.1] - def change - create_table :token_collections do |t| - t.string :standard - t.string :name - t.text :description - t.integer :creator_id - t.string :icon_url - t.integer :items_count - t.integer :holders_count - - t.timestamps - end - end -end diff --git a/db/migrate/20220629012700_create_token_items.rb b/db/migrate/20220629012700_create_token_items.rb deleted file mode 100644 index fe8a73930..000000000 --- a/db/migrate/20220629012700_create_token_items.rb +++ /dev/null @@ -1,18 +0,0 @@ -class CreateTokenItems < ActiveRecord::Migration[6.1] - def change - create_table :token_items do |t| - t.integer :collection_id - t.string :token_id - t.string :name - t.string :icon_url - t.integer :owner_id - t.string :metadata_url - t.integer :cell_id - - t.timestamps - end - add_index :token_items, :owner_id - add_index :token_items, :cell_id - add_index :token_items, [:collection_id, :token_id], unique: true - end -end diff --git a/db/migrate/20220629142603_create_token_transfers.rb b/db/migrate/20220629142603_create_token_transfers.rb deleted file mode 100644 index 58a5f409f..000000000 --- a/db/migrate/20220629142603_create_token_transfers.rb +++ /dev/null @@ -1,16 +0,0 @@ -class CreateTokenTransfers < ActiveRecord::Migration[6.1] - def change - create_table :token_transfers do |t| - t.integer :item_id - t.integer :from_id - t.integer :to_id - t.integer :transaction_id - - t.timestamps - end - add_index :token_transfers, :item_id - add_index :token_transfers, :from_id - add_index :token_transfers, :to_id - add_index :token_transfers, :transaction_id - end -end diff --git a/db/migrate/20220705003300_create_average_block_time_by_hour_view.rb b/db/migrate/20220705003300_create_average_block_time_by_hour_view.rb deleted file mode 100644 index 1aeaf9e8b..000000000 --- a/db/migrate/20220705003300_create_average_block_time_by_hour_view.rb +++ /dev/null @@ -1,28 +0,0 @@ -class CreateAverageBlockTimeByHourView < ActiveRecord::Migration[6.1] - def self.up - execute <<-sql -CREATE MATERIALIZED VIEW IF NOT EXISTS average_block_time_by_hour -AS - SELECT date_trunc('hour'::text, to_timestamp((blocks."timestamp" / 1000.0)::double precision)) AS hour, - avg(blocks.block_time) AS avg_block_time_per_hour - FROM blocks - GROUP BY (date_trunc('hour'::text, to_timestamp((blocks."timestamp" / 1000.0)::double precision))) -WITH DATA; -sql - - execute <<-sql -CREATE MATERIALIZED VIEW IF NOT EXISTS rolling_avg_block_time -TABLESPACE pg_default -AS - SELECT EXTRACT(EPOCH FROM average_block_time_by_hour.hour)::integer as timestamp, - avg(average_block_time_by_hour.avg_block_time_per_hour) OVER (ORDER BY average_block_time_by_hour.hour ROWS BETWEEN 24 PRECEDING AND CURRENT ROW) AS avg_block_time_daily, - avg(average_block_time_by_hour.avg_block_time_per_hour) OVER (ORDER BY average_block_time_by_hour.hour ROWS BETWEEN (7 * 24) PRECEDING AND CURRENT ROW) AS avg_block_time_weekly - FROM average_block_time_by_hour -WITH DATA; -sql - end - - def self.down - execute "DROP MATERIALIZED VIEW IF EXISTS rolling_avg_block_time, average_block_time_by_hour" - end -end diff --git a/db/migrate/20220711181425_add_contained_address_ids_index_to_ckb_transactions.rb b/db/migrate/20220711181425_add_contained_address_ids_index_to_ckb_transactions.rb deleted file mode 100644 index 94f17d553..000000000 --- a/db/migrate/20220711181425_add_contained_address_ids_index_to_ckb_transactions.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddContainedAddressIdsIndexToCkbTransactions < ActiveRecord::Migration[6.1] - disable_ddl_transaction! - def change - execute "create extension btree_gin" rescue nil - add_index :ckb_transactions, [:contained_address_ids, :id], using: :gin, algorithm: :concurrently - end -end diff --git a/db/migrate/20220711183054_remove_old_contained_address_ids_index_from_ckb_transactions.rb b/db/migrate/20220711183054_remove_old_contained_address_ids_index_from_ckb_transactions.rb deleted file mode 100644 index a46ac4690..000000000 --- a/db/migrate/20220711183054_remove_old_contained_address_ids_index_from_ckb_transactions.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RemoveOldContainedAddressIdsIndexFromCkbTransactions < ActiveRecord::Migration[6.1] - def change - remove_index :ckb_transactions, :contained_address_ids - end -end diff --git a/db/migrate/20220716080815_create_ckb_transaction_account_book_trigger.rb b/db/migrate/20220716080815_create_ckb_transaction_account_book_trigger.rb deleted file mode 100644 index 0fdae2174..000000000 --- a/db/migrate/20220716080815_create_ckb_transaction_account_book_trigger.rb +++ /dev/null @@ -1,114 +0,0 @@ - -class CreateCkbTransactionAccountBookTrigger < ActiveRecord::Migration[6.1] - def self.up - execute 'TRUNCATE account_books' - # remove unused fields - remove_column :account_books, :created_at - remove_column :account_books, :updated_at - # add new index - add_index :account_books, [:address_id, :ckb_transaction_id], :unique => true - # remove old index - remove_index :account_books, :address_id - - # create util function - execute <<-sql -CREATE OR REPLACE FUNCTION array_subtract( - minuend anyarray, - subtrahend anyarray, - OUT difference anyarray) - RETURNS anyarray - LANGUAGE 'plpgsql' - COST 100 - VOLATILE STRICT PARALLEL UNSAFE -AS $BODY$ -begin - execute 'select array(select unnest($1) except select unnest($2))' - using minuend, subtrahend - into difference; -end; -$BODY$; - sql - # create trigger function - execute <<-sql -CREATE OR REPLACE FUNCTION synx_tx_to_account_book() - RETURNS trigger - LANGUAGE 'plpgsql' - COST 100 - VOLATILE NOT LEAKPROOF -AS $BODY$ -DECLARE - i int; - to_add int[]; - to_remove int[]; - BEGIN - RAISE NOTICE 'trigger ckb tx(%)', new.id; - if new.contained_address_ids is null then - new.contained_address_ids := array[]::int[]; - end if; - if old is null - then - to_add := new.contained_address_ids; - to_remove := array[]::int[]; - else - - to_add := array_subtract(new.contained_address_ids, old.contained_address_ids); - to_remove := array_subtract(old.contained_address_ids, new.contained_address_ids); - end if; - - if to_add is not null then - FOREACH i IN ARRAY to_add - LOOP - RAISE NOTICE 'ckb_tx_addr_id(%)', i; - insert into account_books (ckb_transaction_id, address_id) - values (new.id, i); - END LOOP; - end if; - if to_remove is not null then - delete from account_books where ckb_transaction_id = new.id and address_id = ANY(to_remove); - end if; - RETURN NEW; - END; -$BODY$; - sql - - execute "DROP TRIGGER IF EXISTS sync_to_account_book ON ckb_transactions" - # create trigger - execute <<-sql - CREATE TRIGGER sync_to_account_book - AFTER INSERT OR UPDATE - ON ckb_transactions - FOR EACH ROW - EXECUTE FUNCTION synx_tx_to_account_book(); - sql - - # create migration procedure - execute <<-sql -CREATE OR REPLACE PROCEDURE sync_full_account_book( - ) -LANGUAGE 'plpgsql' -AS $BODY$ -declare - c cursor for select * from ckb_transactions; - i int; - row RECORD; -begin - open c; - LOOP - FETCH FROM c INTO row; - EXIT WHEN NOT FOUND; - foreach i in array row.contained_address_ids loop - insert into account_books (ckb_transaction_id, address_id) - values (row.id, i) ON CONFLICT DO NOTHING; - end loop; - END LOOP; - close c; -end -$BODY$; - sql - - execute 'CALL sync_full_account_book()' - end - - def self.down - end -end diff --git a/db/migrate/20220718162023_add_symbol_to_token_collection.rb b/db/migrate/20220718162023_add_symbol_to_token_collection.rb deleted file mode 100644 index cab5dba20..000000000 --- a/db/migrate/20220718162023_add_symbol_to_token_collection.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddSymbolToTokenCollection < ActiveRecord::Migration[6.1] - def change - add_column :token_collections, :symbol, :string - add_column :token_collections, :cell_id, :integer - add_column :token_collections, :verified, :boolean, default: false - end -end diff --git a/db/migrate/20220726180124_add_action_to_token_transfer.rb b/db/migrate/20220726180124_add_action_to_token_transfer.rb deleted file mode 100644 index c29b71a32..000000000 --- a/db/migrate/20220726180124_add_action_to_token_transfer.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddActionToTokenTransfer < ActiveRecord::Migration[6.1] - def change - add_column :token_transfers, :action, :integer - change_column :token_transfers, :from_id, :integer, null: true - change_column :token_transfers, :to_id, :integer, null: true - end -end diff --git a/db/migrate/20220727000610_add_type_script_to_nft.rb b/db/migrate/20220727000610_add_type_script_to_nft.rb deleted file mode 100644 index 1029a0a74..000000000 --- a/db/migrate/20220727000610_add_type_script_to_nft.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddTypeScriptToNFT < ActiveRecord::Migration[6.1] - def change - add_column :token_collections, :type_script_id, :integer - add_column :token_items, :type_script_id, :integer - end -end diff --git a/db/migrate/20220801080617_add_uan_fields.rb b/db/migrate/20220801080617_add_uan_fields.rb deleted file mode 100644 index 94d99162b..000000000 --- a/db/migrate/20220801080617_add_uan_fields.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddUanFields < ActiveRecord::Migration[6.1] - def change - add_column :udts, :display_name, :string - add_column :udts, :uan, :string - end -end diff --git a/db/migrate/20220803030716_add_index_to_materialized_views.rb b/db/migrate/20220803030716_add_index_to_materialized_views.rb deleted file mode 100644 index 9355a123c..000000000 --- a/db/migrate/20220803030716_add_index_to_materialized_views.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddIndexToMaterializedViews < ActiveRecord::Migration[6.1] - def change - add_index :average_block_time_by_hour, :hour, unique: true - add_index :rolling_avg_block_time, :timestamp, unique: true - end -end diff --git a/db/migrate/20220822155712_add_index_to_token_collection.rb b/db/migrate/20220822155712_add_index_to_token_collection.rb deleted file mode 100644 index 8fa8e9895..000000000 --- a/db/migrate/20220822155712_add_index_to_token_collection.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddIndexToTokenCollection < ActiveRecord::Migration[6.1] - def change - add_index :token_collections, :cell_id - add_index :token_items, :type_script_id - add_index :token_collections, :type_script_id - end -end diff --git a/db/migrate/20220830023203_change_token_id_to_int.rb b/db/migrate/20220830023203_change_token_id_to_int.rb deleted file mode 100644 index 4e51d432d..000000000 --- a/db/migrate/20220830023203_change_token_id_to_int.rb +++ /dev/null @@ -1,12 +0,0 @@ -class ChangeTokenIdToInt < ActiveRecord::Migration[6.1] - def change - reversible do |dir| - dir.up do - change_column :token_items, :token_id, "integer USING CAST(token_id AS integer)" - end - dir.down do - change_column :token_items, :token_id, :string - end - end - end -end diff --git a/db/migrate/20220830163001_add_type_script_id_index.rb b/db/migrate/20220830163001_add_type_script_id_index.rb deleted file mode 100644 index 539a3f166..000000000 --- a/db/migrate/20220830163001_add_type_script_id_index.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddTypeScriptIdIndex < ActiveRecord::Migration[6.1] - def change - add_index :cell_outputs, [:type_script_id, :id] - end -end diff --git a/db/migrate/20220904005610_add_sn_to_token_collection.rb b/db/migrate/20220904005610_add_sn_to_token_collection.rb deleted file mode 100644 index 38b3dad21..000000000 --- a/db/migrate/20220904005610_add_sn_to_token_collection.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddSnToTokenCollection < ActiveRecord::Migration[6.1] - def change - add_column :token_collections, :sn, :string - add_index :token_collections, :sn, unique: true - end -end diff --git a/db/migrate/20220912154933_change_token_id_to_decimal.rb b/db/migrate/20220912154933_change_token_id_to_decimal.rb deleted file mode 100644 index f1a35defc..000000000 --- a/db/migrate/20220912154933_change_token_id_to_decimal.rb +++ /dev/null @@ -1,12 +0,0 @@ -class ChangeTokenIdToDecimal < ActiveRecord::Migration[6.1] - def change - reversible do |dir| - dir.up do - change_column :token_items, :token_id, :decimal, precision: 80 - end - dir.down do - change_column :token_items, :token_id, :integer - end - end - end -end diff --git a/db/migrate/20221009072146_change_index_type_for_addresses.rb b/db/migrate/20221009072146_change_index_type_for_addresses.rb deleted file mode 100644 index 5e1538a45..000000000 --- a/db/migrate/20221009072146_change_index_type_for_addresses.rb +++ /dev/null @@ -1,23 +0,0 @@ -class ChangeIndexTypeForAddresses < ActiveRecord::Migration[6.1] - def self.up - remove_index :addresses, name: "index_addresses_on_address_hash_crc" rescue nil - remove_index :addresses, name: "index_addresses_on_lock_hash" rescue nil - - add_index :addresses, :address_hash, using: "hash" - add_index :addresses, :lock_hash, using: "hash" - execute "alter table public.addresses add constraint unique_lock_hash unique (lock_hash);" - - remove_column :addresses, :address_hash_crc - end - - def self.down - add_column :addresses, :address_hash_crc, :bigint - - execute "alter table public.addresses drop constraint unique_lock_hash;" - remove_index :addresses, name: "index_addresses_on_lock_hash" - remove_index :addresses, name: "index_addresses_on_address_hash" - - add_index :addresses, :lock_hash - add_index :addresses, :address_hash_crc - end -end diff --git a/db/migrate/20221009073948_change_index_type_for_blocks.rb b/db/migrate/20221009073948_change_index_type_for_blocks.rb deleted file mode 100644 index 0d227adb6..000000000 --- a/db/migrate/20221009073948_change_index_type_for_blocks.rb +++ /dev/null @@ -1,11 +0,0 @@ -class ChangeIndexTypeForBlocks < ActiveRecord::Migration[6.1] - def self.up - remove_index :blocks, name: "index_blocks_on_block_hash" - add_index :blocks, :block_hash, using: 'hash' - end - - def self.down - remove_index :blocks, name: "index_blocks_on_block_hash" - add_index :blocks, :block_hash - end -end diff --git a/db/migrate/20221009075753_change_index_type_for_lock_scripts.rb b/db/migrate/20221009075753_change_index_type_for_lock_scripts.rb deleted file mode 100644 index b0faed6f3..000000000 --- a/db/migrate/20221009075753_change_index_type_for_lock_scripts.rb +++ /dev/null @@ -1,11 +0,0 @@ -class ChangeIndexTypeForLockScripts < ActiveRecord::Migration[6.1] - def self.up - remove_index :lock_scripts, name: "index_lock_scripts_on_script_hash" - add_index :lock_scripts, :script_hash, using: 'hash' - end - - def self.down - remove_index :lock_scripts, name: "index_lock_scripts_on_script_hash" - add_index :lock_scripts, :script_hash - end -end diff --git a/db/migrate/20221009080035_change_index_type_for_pool_transaction_entries.rb b/db/migrate/20221009080035_change_index_type_for_pool_transaction_entries.rb deleted file mode 100644 index e79289b3b..000000000 --- a/db/migrate/20221009080035_change_index_type_for_pool_transaction_entries.rb +++ /dev/null @@ -1,13 +0,0 @@ -class ChangeIndexTypeForPoolTransactionEntries < ActiveRecord::Migration[6.1] - def self.up - remove_index :pool_transaction_entries, name: "index_pool_transaction_entries_on_tx_hash" - add_index :pool_transaction_entries, :tx_hash, using: 'hash' - execute "alter table public.pool_transaction_entries add constraint unique_tx_hash unique (tx_hash);" - end - - def self.down - execute "alter table public.pool_transaction_entries drop constraint unique_tx_hash;" - remove_index :pool_transaction_entries, name: "index_pool_transaction_entries_on_tx_hash" - add_index :pool_transaction_entries, :tx_hash - end -end diff --git a/db/migrate/20221009080306_change_index_type_for_token_collections.rb b/db/migrate/20221009080306_change_index_type_for_token_collections.rb deleted file mode 100644 index 32be4a228..000000000 --- a/db/migrate/20221009080306_change_index_type_for_token_collections.rb +++ /dev/null @@ -1,13 +0,0 @@ -class ChangeIndexTypeForTokenCollections< ActiveRecord::Migration[6.1] - def self.up - remove_index :token_collections, name: "index_token_collections_on_sn" - add_index :token_collections, :sn, using: 'hash' - execute "alter table public.token_collections add constraint unique_sn unique (sn);" - end - - def self.down - execute "alter table public.token_collections drop constraint unique_sn;" - remove_index :token_collections, name: "index_token_collections_on_sn" - add_index :token_collections, :sn - end -end diff --git a/db/migrate/20221009080708_change_index_type_for_type_scripts.rb b/db/migrate/20221009080708_change_index_type_for_type_scripts.rb deleted file mode 100644 index 796da7abe..000000000 --- a/db/migrate/20221009080708_change_index_type_for_type_scripts.rb +++ /dev/null @@ -1,11 +0,0 @@ -class ChangeIndexTypeForTypeScripts < ActiveRecord::Migration[6.1] - def self.up - remove_index :type_scripts, name: "index_type_scripts_on_script_hash" - add_index :type_scripts, :script_hash, using: 'hash' - end - - def self.down - remove_index :type_scripts, name: "index_type_scripts_on_script_hash" - add_index :type_scripts, :script_hash - end -end diff --git a/db/migrate/20221009081118_change_index_type_for_udts.rb b/db/migrate/20221009081118_change_index_type_for_udts.rb deleted file mode 100644 index c8a7a5029..000000000 --- a/db/migrate/20221009081118_change_index_type_for_udts.rb +++ /dev/null @@ -1,13 +0,0 @@ -class ChangeIndexTypeForUdts < ActiveRecord::Migration[6.1] - def self.up - remove_index :udts, name: "index_udts_on_type_hash" - add_index :udts, :type_hash, using: 'hash' - execute "alter table public.udts add constraint unique_type_hash unique (type_hash);" - end - - def self.down - execute "alter table public.udts drop constraint unique_type_hash;" - remove_index :udts, name: "index_udts_on_type_hash" - add_index :udts, :type_hash - end -end diff --git a/db/migrate/20221024021923_add_detailed_message_to_pool_transaction_entries.rb b/db/migrate/20221024021923_add_detailed_message_to_pool_transaction_entries.rb deleted file mode 100644 index 0b174c8f1..000000000 --- a/db/migrate/20221024021923_add_detailed_message_to_pool_transaction_entries.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddDetailedMessageToPoolTransactionEntries < ActiveRecord::Migration[6.1] - def change - add_column :pool_transaction_entries, :detailed_message, :text - end -end diff --git a/db/migrate/20221030235723_add_median_timestamp_to_blocks.rb b/db/migrate/20221030235723_add_median_timestamp_to_blocks.rb deleted file mode 100644 index 23d3dc29d..000000000 --- a/db/migrate/20221030235723_add_median_timestamp_to_blocks.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddMedianTimestampToBlocks < ActiveRecord::Migration[6.1] - def change - add_column :blocks, :median_timestamp, :decimal, default: 0 - end -end diff --git a/db/migrate/20221031085901_add_median_timestamp_to_forked_blocks.rb b/db/migrate/20221031085901_add_median_timestamp_to_forked_blocks.rb deleted file mode 100644 index 0e7b705c6..000000000 --- a/db/migrate/20221031085901_add_median_timestamp_to_forked_blocks.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddMedianTimestampToForkedBlocks < ActiveRecord::Migration[6.1] - def change - add_column :forked_blocks, :median_timestamp, :decimal, default: 0 - end -end diff --git a/db/migrate/20221106174818_add_bytes_to_ckb_transaction.rb b/db/migrate/20221106174818_add_bytes_to_ckb_transaction.rb deleted file mode 100644 index 2f558f65c..000000000 --- a/db/migrate/20221106174818_add_bytes_to_ckb_transaction.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddBytesToCkbTransaction < ActiveRecord::Migration[6.1] - def change - add_column :ckb_transactions, :bytes, :integer, default: 0 - end -end diff --git a/db/migrate/20221106182302_add_bytes_to_pool_transaction.rb b/db/migrate/20221106182302_add_bytes_to_pool_transaction.rb deleted file mode 100644 index cf9a9ae25..000000000 --- a/db/migrate/20221106182302_add_bytes_to_pool_transaction.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddBytesToPoolTransaction < ActiveRecord::Migration[6.1] - def change - add_column :pool_transaction_entries, :bytes, :integer, default: 0 - end -end diff --git a/db/migrate/20221108035020_create_index_for_id_and_tx_status_for_pool_transaction_entries.rb b/db/migrate/20221108035020_create_index_for_id_and_tx_status_for_pool_transaction_entries.rb deleted file mode 100644 index a42addc93..000000000 --- a/db/migrate/20221108035020_create_index_for_id_and_tx_status_for_pool_transaction_entries.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateIndexForIdAndTxStatusForPoolTransactionEntries < ActiveRecord::Migration[6.1] - def self.up - add_index :pool_transaction_entries, [:id, :tx_status] - end - - def self.down - remove_index :pool_transaction_entries, name: "index_pool_transaction_entries_on_id_and_tx_status" - end -end diff --git a/db/migrate/20221213075412_add_largest_info_to_epoch_statistic.rb b/db/migrate/20221213075412_add_largest_info_to_epoch_statistic.rb deleted file mode 100644 index bd1905e26..000000000 --- a/db/migrate/20221213075412_add_largest_info_to_epoch_statistic.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddLargestInfoToEpochStatistic < ActiveRecord::Migration[7.0] - def change - add_column :epoch_statistics, :largest_block_number, :integer - add_column :epoch_statistics, :largest_block_size, :integer - add_column :epoch_statistics, :largest_tx_hash, :binary - add_column :epoch_statistics, :largest_tx_bytes, :integer - end -end diff --git a/db/migrate/20221227013538_create_counters.rb b/db/migrate/20221227013538_create_counters.rb deleted file mode 100644 index 64f5510dc..000000000 --- a/db/migrate/20221227013538_create_counters.rb +++ /dev/null @@ -1,59 +0,0 @@ -class CreateCounters < ActiveRecord::Migration[7.0] - def self.up - create_table :counters do |t| - t.string :name, comment: "the name of the table" - t.integer :value, comment: "the count value of the table" - t.timestamps - end - - # defined trigger and postgres functions - # so that it is able to update the table's count automatically when insert/delete. - raw_sql = %{ -CREATE OR REPLACE FUNCTION increase_ckb_transactions_count() RETURNS TRIGGER AS -$$begin - UPDATE counters SET value = value + 1 WHERE name = 'ckb_transactions'; - RETURN NEW; -end;$$ -LANGUAGE PLPGSQL VOLATILE; - -CREATE OR REPLACE TRIGGER after_insert_update_ckb_transactions_count -AFTER INSERT ON ckb_transactions -FOR EACH ROW EXECUTE PROCEDURE increase_ckb_transactions_count(); - -CREATE OR REPLACE FUNCTION decrease_ckb_transactions_count() RETURNS TRIGGER AS -$$begin - UPDATE counters SET value = value - 1 WHERE name = 'ckb_transactions'; - RETURN NEW; -end;$$ -LANGUAGE PLPGSQL VOLATILE; - -CREATE OR REPLACE TRIGGER after_delete_update_ckb_transactions_count -AFTER DELETE ON ckb_transactions -FOR EACH ROW EXECUTE PROCEDURE decrease_ckb_transactions_count(); - } - - execute(raw_sql) - execute <<-SQL - BEGIN WORK; - lock table ckb_transactions in SHARE ROW EXCLUSIVE MODE; - insert into counters - (name, value, created_at, updated_at) - values ('ckb_transactions', (select count(*) from ckb_transactions), now(), now()) - ; - COMMIT WORK; - SQL - end - - def self.down - raw_sql = %{ - DROP FUNCTION IF EXISTS increase_ckb_transactions_count() CASCADE; - DROP FUNCTION IF EXISTS decrease_ckb_transactions_count() CASCADE; - DROP TRIGGER IF EXISTS after_insert_update_ckb_transactions_count ON ckb_transactions; - DROP TRIGGER IF EXISTS after_delete_update_ckb_transactions_count ON ckb_transactions; - } - - execute(raw_sql) - - drop_table :counters - end -end diff --git a/db/migrate/20221228102920_add_status_to_token_items.rb b/db/migrate/20221228102920_add_status_to_token_items.rb deleted file mode 100644 index 5cffb4ea6..000000000 --- a/db/migrate/20221228102920_add_status_to_token_items.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddStatusToTokenItems < ActiveRecord::Migration[7.0] - def change - add_column :token_items, :status, :integer, default: 1 - end -end diff --git a/db/migrate/20221230022643_add_ckb_node_version_to_blocks.rb b/db/migrate/20221230022643_add_ckb_node_version_to_blocks.rb deleted file mode 100644 index ecd12e4df..000000000 --- a/db/migrate/20221230022643_add_ckb_node_version_to_blocks.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddCkbNodeVersionToBlocks < ActiveRecord::Migration[7.0] - def change - add_column :blocks, :ckb_node_version, :string, default: nil, comment: 'ckb node version, e.g. 0.105.1' - add_column :forked_blocks, :ckb_node_version, :string, default: nil, comment: 'ckb node version, e.g. 0.105.1' - end -end diff --git a/db/migrate/20230101045136_add_cycles_to_transaction.rb b/db/migrate/20230101045136_add_cycles_to_transaction.rb deleted file mode 100644 index 9961bdf4b..000000000 --- a/db/migrate/20230101045136_add_cycles_to_transaction.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCyclesToTransaction < ActiveRecord::Migration[7.0] - def change - add_column :ckb_transactions, :cycles, :integer - end -end diff --git a/db/migrate/20230104093413_add_max_cycles.rb b/db/migrate/20230104093413_add_max_cycles.rb deleted file mode 100644 index 3280ff99d..000000000 --- a/db/migrate/20230104093413_add_max_cycles.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddMaxCycles < ActiveRecord::Migration[7.0] - def change - add_column :epoch_statistics, :max_block_cycles, :integer - add_column :epoch_statistics, :max_tx_cycles, :integer - add_column :blocks, :cycles, :integer - end -end diff --git a/db/migrate/20230106111415_add_cycles_to_forked_block.rb b/db/migrate/20230106111415_add_cycles_to_forked_block.rb deleted file mode 100644 index 5ca083de1..000000000 --- a/db/migrate/20230106111415_add_cycles_to_forked_block.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCyclesToForkedBlock < ActiveRecord::Migration[7.0] - def change - add_column :forked_blocks, :cycles, :integer - end -end diff --git a/db/migrate/20230114022237_add_confirmation_time_to_ckb_transactions.rb b/db/migrate/20230114022237_add_confirmation_time_to_ckb_transactions.rb deleted file mode 100644 index 9fa410de8..000000000 --- a/db/migrate/20230114022237_add_confirmation_time_to_ckb_transactions.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddConfirmationTimeToCkbTransactions < ActiveRecord::Migration[7.0] - def change - add_column :ckb_transactions, :confirmation_time, :integer, comment: 'it cost how many seconds to confirm this transaction' - end -end diff --git a/db/migrate/20230117035205_create_contracts.rb b/db/migrate/20230117035205_create_contracts.rb deleted file mode 100644 index d3b722fb4..000000000 --- a/db/migrate/20230117035205_create_contracts.rb +++ /dev/null @@ -1,73 +0,0 @@ -class CreateContracts < ActiveRecord::Migration[7.0] - def self.up - create_table :contracts do |t| - t.binary :code_hash - t.string :hash_type - t.string :deployed_args - t.string :role, default: 'type_script' - t.string :name - t.string :symbol - t.string :description - t.boolean :verified, default: false - - t.timestamps null: false - end - - add_index :contracts, :code_hash - add_index :contracts, :hash_type - add_index :contracts, :name - add_index :contracts, :role - add_index :contracts, :symbol - add_index :contracts, :verified - if ENV['CKB_NET_MODE'] == 'mainnet' - hashes = [ - { code_hash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8', hash_type: 'type', name: 'SECP256K1/blake160', description: 'SECP256K1/blake160 is the default lock script to verify CKB transaction signature.', role: 'lock_script' }, - { code_hash: '0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8', hash_type: 'type', name: 'SECP256K1/multisig', description: 'SECP256K1/multisig is a script which allows a group of users to sign a single transaction.', role: 'lock_script' }, - { code_hash: '0xd369597ff47f29fbc0d47d2e3775370d1250b85140c670e4718af712983a2354', hash_type: 'type', name: 'Anyone-Can-Pay Lock', description: 'anyone_can_pay allows a recipient to provide cell capacity in asset transfer.', role: 'type_script' }, - { code_hash: '0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e', hash_type: 'type', name: 'Nervos DAO', description: 'Nervos DAO is a smart contract with which users can interact the same way as any smart contract on CKB.', role: 'type_script' }, - { code_hash: '0x5e7a36a77e68eecc013dfa2fe6a23f3b6c344b04005808694ae6dd45eea4cfd5', hash_type: 'type', name: 'Simple UDT', description: 'Simple UDT provides a way for dapp developers to issue custom tokens on Nervos CKB.', role: 'type_script' }, - { code_hash: '0xd01f5152c267b7f33b9795140c2467742e8424e49ebe2331caec197f7281b60a', hash_type: 'type', name: 'Unipass', description: 'Simple UDT provides a way for dapp developers to issue custom tokens on Nervos CKB.', role: 'type_script' }, - { code_hash: '0x1122a4fb54697cf2e6e3a96c9d80fd398a936559b90954c6e88eb7ba0cf652df', hash_type: 'type', name: 'CoTA', description: 'A Compact Token Aggregator Standard for Extremely Low Cost NFTs and FTs.', role: 'type_script' }, - { code_hash: '0x90ca618be6c15f5857d3cbd09f9f24ca6770af047ba9ee70989ec3b229419ac7', hash_type: 'type', name: 'CoTA Registry', description: 'A Compact Token Aggregator Standard for Extremely Low Cost NFTs and FTs.', role: 'type_script' }, - { code_hash: '0xbf43c3602455798c1a61a596e0d95278864c552fafe231c063b3fabf97a8febc', hash_type: 'type', name: 'PW Lock', description: "Forked from CKB's system scripts, and currently supports signature generated by personalSign and signTypedData from ethereum wallets.", role: 'type_script' }, - { code_hash: '0x000f87062a2fe9bb4a6cc475212ea11014b84deb32e0375ee51e6ec4a553e009', hash_type: 'type', name: 'godwoken_custodian_lock', description: 'Rollup uses the custodian lock to hold the deposited assets.', role: 'type_script' }, - { code_hash: '0xff602581f07667eef54232cce850cbca2c418b3418611c132fca849d1edcd775', hash_type: 'type', name: 'godwoken_deposit_lock', description: 'A layer1 user can join the Rollup by creating a deposit cell.', role: 'type_script' }, - { code_hash: '0x3714af858b8b82b2bb8f13d51f3cffede2dd8d352a6938334bb79e6b845e3658', hash_type: 'type', name: 'godwoken_withdrawal_lock', description: 'Withdrawal cells are generated in the RollupSubmitBlock action according to the block.withdrawals field.', role: 'type_script' }, - { code_hash: '0x628b5f956b46ae27b50819a9ebab79ce5f957e6899ba0c75b8e142de2ed0dcd2', hash_type: 'type', name: 'godwoken_challenge_lock', description: 'When a Godwoken node found that an invalid state exists in the Rollup, the node can send the RollupEnterChallenge action to the Rollup cell and generate a challenging cell.' }, - { code_hash: '0xb619184ab9142c51b0ee75f4e24bcec3d077eefe513115bad68836d06738fd2c', hash_type: 'type', name: 'godwoken_stake_lock', description: 'A block producer is required to provide a stake cell to perform the RollupSubmitBlock action.', role: 'type_script' }, - { code_hash: '0xa4398768d87bd17aea1361edc3accd6a0117774dc4ebc813bfa173e8ac0d086d', hash_type: 'type', name: 'omni_lock v1', description: 'Omnilock is a lock script designed for interoperability. It comes with built-in support for verification of transaction signing methods used in Bitcoin, Ethereum, EOS, and Dogecoin. Omnilock is also extensible, so more verification algorithms can be added in future.', role: 'lock_script' }, - { code_hash: '0x9b819793a64463aed77c615d6cb226eea5487ccfc0783043a587254cda2b6f26', hash_type: 'type', name: 'omni_lock v2', description: 'Omnilock is a lock script designed for interoperability. It comes with built-in support for verification of transaction signing methods used in Bitcoin, Ethereum, EOS, and Dogecoin. Omnilock is also extensible, so more verification algorithms can be added in future.', role: 'lock_script' }, - { code_hash: '0xfef1d086d9f74d143c60bf03bd04bab29200dbf484c801c72774f2056d4c6718', hash_type: 'type', name: 'godwoken_state_validator', description: 'State validator is the major script to verify the on-chain Rollup cell. Rollup cell is an identity cell on CKB, it stores the structure GlobalState which represents the layer-2 state.', role: 'type_script' }, - { code_hash: '0x096df264f38fff07f3acd318995abc2c71ae0e504036fe32bc38d5b6037364d4', hash_type: 'type', name: 'godwoken_eth_account_lock', description: 'A layer-2 lock script, ETH account lock is a script that verifies the layer-2 account signature.', role: 'type_script' } - ] - else - hashes = [ - { code_hash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8', hash_type: 'type', name: 'SECP256K1/blake160', description: 'SECP256K1/blake160 is the default lock script to verify CKB transaction signature.', role:'lock_script' }, - { code_hash: '0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8', hash_type: 'type', name: 'SECP256K1/multisig', description: 'SECP256K1/multisig is a script which allows a group of users to sign a single transaction.', role:'lock_script' }, - { code_hash: '0x3419a1c09eb2567f6552ee7a8ecffd64155cffe0f1796e6e61ec088d740c1356', hash_type: 'type', name: 'Anyone-Can-Pay Lock', description: 'anyone_can_pay allows a recipient to provide cell capacity in asset transfer.', role: 'type_script' }, - { code_hash: '0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e', hash_type: 'type', name: 'Nervos DAO', description: 'Nervos DAO is a smart contract with which users can interact the same way as any smart contract on CKB.', role: 'type_script' }, - { code_hash: '0xc5e5dcf215925f7ef4dfaf5f4b4f105bc321c02776d6e7d52a1db3fcd9d011a4', hash_type: 'type', name: 'Simple UDT', description: 'Simple UDT provides a way for dapp developers to issue custom tokens on Nervos CKB.' , role: 'type_script'}, - { code_hash: '0x3e1eb7ed4809b2d60650be96a40abfbdafb3fb942b7b37ec7709e64e2cd0a783', hash_type: 'type', name: 'Unipass', description: 'Simple UDT provides a way for dapp developers to issue custom tokens on Nervos CKB.', role: 'type_script' }, - { code_hash: '0x89cd8003a0eaf8e65e0c31525b7d1d5c1becefd2ea75bb4cff87810ae37764d8', hash_type: 'type', name: 'CoTA', description: 'A Compact Token Aggregator Standard for Extremely Low Cost NFTs and FTs.', role: 'type_script' }, - { code_hash: '0x9302db6cc1344b81a5efee06962abcb40427ecfcbe69d471b01b2658ed948075', hash_type: 'type', name: 'CoTA Registry', description: 'A Compact Token Aggregator Standard for Extremely Low Cost NFTs and FTs.', role: 'type_script', role: 'type_script' }, - { code_hash: '0x58c5f491aba6d61678b7cf7edf4910b1f5e00ec0cde2f42e0abb4fd9aff25a63', hash_type: 'type', name: 'PW Lock', description: "Forked from CKB's system scripts, and currently supports signature generated by personalSign and signTypedData from ethereum wallets.", role: 'type_script' }, - { code_hash: '0x85ae4db0dd83f428a31deb342e4000af37ce2c9645d9e619df00096e3c50a2bb', hash_type: 'type', name: 'godwoken_custodian_lock', description: 'Rollup uses the custodian lock to hold the deposited assets.', role: 'type_script' }, - { code_hash: '0x50704b84ecb4c4b12b43c7acb260ddd69171c21b4c0ba15f3c469b7d143f6f18', hash_type: 'type', name: 'godwoken_deposit_lock', description: 'A layer1 user can join the Rollup by creating a deposit cell.', role: 'type_script' }, - { code_hash: '0x06ae0706bb2d7997d66224741d3ec7c173dbb2854a6d2cf97088796b677269c6', hash_type: 'type', name: 'godwoken_withdrawal_lock', description: 'Withdrawal cells are generated in the RollupSubmitBlock action according to the block.withdrawals field.', role: 'type_script' }, - { code_hash: '0x5a86c3bf1e8648b6a6f8abe6875720ccf9745ab225b68fa7c195f9d6635dea80', hash_type: 'type', name: 'godwoken_challenge_lock', description: 'When a Godwoken node found that an invalid state exists in the Rollup, the node can send the RollupEnterChallenge action to the Rollup cell and generate a challenging cell.', role: 'type_script', role: 'type_script' }, - { code_hash: '0x7f5a09b8bd0e85bcf2ccad96411ccba2f289748a1c16900b0635c2ed9126f288', hash_type: 'type', name: 'godwoken_stake_lock', description: 'A block producer is required to provide a stake cell to perform the RollupSubmitBlock action.', role: 'type_script' }, - { code_hash: '0x79f90bb5e892d80dd213439eeab551120eb417678824f282b4ffb5f21bad2e1e', hash_type: 'type', name: 'omni_lock v1', description: 'Omnilock is a lock script designed for interoperability. It comes with built-in support for verification of transaction signing methods used in Bitcoin, Ethereum, EOS, and Dogecoin. Omnilock is also extensible, so more verification algorithms can be added in future.', role: 'lock_script' }, - { code_hash: '0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb', hash_type: 'type', name: 'omni_lock v2', description: 'Omnilock is a lock script designed for interoperability. It comes with built-in support for verification of transaction signing methods used in Bitcoin, Ethereum, EOS, and Dogecoin. Omnilock is also extensible, so more verification algorithms can be added in future.', role: 'lock_script' }, - { code_hash: '0x1e44736436b406f8e48a30dfbddcf044feb0c9eebfe63b0f81cb5bb727d84854', hash_type: 'type', name: 'godwoken_state_validator', description: 'State validator is the major script to verify the on-chain Rollup cell. Rollup cell is an identity cell on CKB, it stores the structure GlobalState which represents the layer-2 state.', role: 'type_script' }, - { code_hash: '0x07521d0aa8e66ef441ebc31204d86bb23fc83e9edc58c19dbb1b0ebe64336ec0', hash_type: 'type', name: 'godwoken_eth_account_lock', description: 'A layer-2 lock script, ETH account lock is a script that verifies the layer-2 account signature.', role: 'type_script' } - ] - end - - hashes.each {|hash| Contract.create hash } - end - - def self.down - drop_table :contracts - end - -end diff --git a/db/migrate/20230128015428_create_deployed_cells.rb b/db/migrate/20230128015428_create_deployed_cells.rb deleted file mode 100644 index 480c4d1c4..000000000 --- a/db/migrate/20230128015428_create_deployed_cells.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateDeployedCells < ActiveRecord::Migration[7.0] - def change - create_table :deployed_cells do |t| - t.bigint :cell_output_id - t.bigint :contract_id - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20230128015956_create_scripts.rb b/db/migrate/20230128015956_create_scripts.rb deleted file mode 100644 index 95f7dca8c..000000000 --- a/db/migrate/20230128015956_create_scripts.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateScripts < ActiveRecord::Migration[7.0] - def change - create_table :scripts do |t| - t.string :args - t.string :script_hash - t.boolean :is_contract, default: false - t.bigint :contract_id - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20230128031939_add_script_id_to_type_scripts_and_lock_scripts.rb b/db/migrate/20230128031939_add_script_id_to_type_scripts_and_lock_scripts.rb deleted file mode 100644 index 16071c47a..000000000 --- a/db/migrate/20230128031939_add_script_id_to_type_scripts_and_lock_scripts.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddScriptIdToTypeScriptsAndLockScripts < ActiveRecord::Migration[7.0] - def change - add_column :type_scripts, :script_id, :bigint - add_column :lock_scripts, :script_id, :bigint - end -end diff --git a/db/migrate/20230129165127_create_udt_transactions.rb b/db/migrate/20230129165127_create_udt_transactions.rb deleted file mode 100644 index f23dbc70e..000000000 --- a/db/migrate/20230129165127_create_udt_transactions.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateUdtTransactions < ActiveRecord::Migration[7.0] - def change - create_table :udt_transactions, id: false do |t| - t.references :udt, foreign_key: { on_delete: :cascade } - t.references :ckb_transaction, index: true, foreign_key: { on_delete: :cascade } - t.index [:udt_id, :ckb_transaction_id], name: "pk", unique: true - end - end -end diff --git a/db/migrate/20230206073806_add_issuance_to_block_statistic.rb b/db/migrate/20230206073806_add_issuance_to_block_statistic.rb deleted file mode 100644 index f1fb1f256..000000000 --- a/db/migrate/20230206073806_add_issuance_to_block_statistic.rb +++ /dev/null @@ -1,10 +0,0 @@ -class AddIssuanceToBlockStatistic < ActiveRecord::Migration[7.0] - def change - add_column :block_statistics, :primary_issuance, :decimal, precision: 36, scale: 8 - add_column :block_statistics, :secondary_issuance, :decimal, precision: 36, scale: 8 - add_column :block_statistics, :total_issuance, :decimal, precision: 36, scale: 8, comment: "C_i in DAO header (accumulated deposits)" - add_column :block_statistics, :accumulated_rate, :decimal, precision: 36, scale: 8, comment: "AR_i in DAO header" - add_column :block_statistics, :unissued_secondary_issuance, :decimal, precision: 36, scale: 8, comment: "S_i in DAO header" - add_column :block_statistics, :total_occupied_capacities, :decimal, precision: 36, scale: 8, comment: "U_i in DAO header" - end -end diff --git a/db/migrate/20230207112513_rename_total_issuance.rb b/db/migrate/20230207112513_rename_total_issuance.rb deleted file mode 100644 index 17d302aa9..000000000 --- a/db/migrate/20230207112513_rename_total_issuance.rb +++ /dev/null @@ -1,6 +0,0 @@ -class RenameTotalIssuance < ActiveRecord::Migration[7.0] - def change - rename_column :block_statistics, :total_issuance, :accumulated_total_deposits - # Ex:- rename_column("admin_users", "pasword","hashed_pasword") - end -end diff --git a/db/migrate/20230208081700_rename_counters_to_global_statistics.rb b/db/migrate/20230208081700_rename_counters_to_global_statistics.rb deleted file mode 100644 index bc349ad5a..000000000 --- a/db/migrate/20230208081700_rename_counters_to_global_statistics.rb +++ /dev/null @@ -1,120 +0,0 @@ -class RenameCountersToGlobalStatistics < ActiveRecord::Migration[7.0] - def self.up - # remove counters and related triggers - raw_sql = %{ -DROP FUNCTION IF EXISTS increase_ckb_transactions_count() CASCADE; -DROP FUNCTION IF EXISTS decrease_ckb_transactions_count() CASCADE; -DROP TRIGGER IF EXISTS after_insert_update_ckb_transactions_count ON ckb_transactions; -DROP TRIGGER IF EXISTS after_delete_update_ckb_transactions_count ON ckb_transactions; - } - - ActiveRecord::Base.connection.execute(raw_sql) - - drop_table :counters - - # create for global_statistics - create_table :global_statistics do |t| - t.string :name, comment: "the name of something, e.g. my_table_rows_count" - t.integer :value, comment: "value of something, e.g. 888" - t.string :comment, - t.timestamps - end - - # defined trigger and postgres functions - # so that it is able to update the table's count automatically when insert/delete. - raw_sql = %{ -CREATE FUNCTION increase_ckb_transactions_count() RETURNS TRIGGER AS -$$begin - UPDATE global_statistics SET value = value + 1 WHERE name = 'ckb_transactions'; - RETURN NEW; -end;$$ -LANGUAGE PLPGSQL VOLATILE; - -CREATE TRIGGER after_insert_update_ckb_transactions_count -AFTER INSERT ON ckb_transactions -FOR EACH ROW EXECUTE PROCEDURE increase_ckb_transactions_count(); - -CREATE FUNCTION decrease_ckb_transactions_count() RETURNS TRIGGER AS -$$begin - UPDATE global_statistics SET value = value - 1 WHERE name = 'ckb_transactions'; - RETURN NEW; -end;$$ -LANGUAGE PLPGSQL VOLATILE; - -CREATE TRIGGER after_delete_update_ckb_transactions_count -AFTER DELETE ON ckb_transactions -FOR EACH ROW EXECUTE PROCEDURE decrease_ckb_transactions_count(); - } - - execute(raw_sql) - - execute <<-SQL - BEGIN WORK; - lock table ckb_transactions in SHARE ROW EXCLUSIVE MODE; - insert into global_statistics - (name, value, created_at, updated_at) - values ('ckb_transactions', (select count(*) from ckb_transactions), now(), now()) - ; - COMMIT WORK; - SQL - end - - def self.down - # down for global_statistics - raw_sql = %{ -DROP FUNCTION IF EXISTS increase_ckb_transactions_count() CASCADE; -DROP FUNCTION IF EXISTS decrease_ckb_transactions_count() CASCADE; -DROP TRIGGER IF EXISTS after_insert_update_ckb_transactions_count ON ckb_transactions; -DROP TRIGGER IF EXISTS after_delete_update_ckb_transactions_count ON ckb_transactions; - } - - execute(raw_sql) - - drop_table :global_statistics - - # down for counters - create_table :counters do |t| - t.string :name, comment: "the name of the table" - t.integer :value, comment: "the count value of the table" - t.timestamps - end - - # defined trigger and postgres functions - # so that it is able to update the table's count automatically when insert/delete. - raw_sql = %{ -CREATE FUNCTION increase_ckb_transactions_count() RETURNS TRIGGER AS -$$begin - UPDATE counters SET value = value + 1 WHERE name = 'ckb_transactions'; - RETURN NEW; -end;$$ -LANGUAGE PLPGSQL VOLATILE; - -CREATE TRIGGER after_insert_update_ckb_transactions_count -AFTER INSERT ON ckb_transactions -FOR EACH ROW EXECUTE PROCEDURE increase_ckb_transactions_count(); - -CREATE FUNCTION decrease_ckb_transactions_count() RETURNS TRIGGER AS -$$begin - UPDATE counters SET value = value - 1 WHERE name = 'ckb_transactions'; - RETURN NEW; -end;$$ -LANGUAGE PLPGSQL VOLATILE; - -CREATE TRIGGER after_delete_update_ckb_transactions_count -AFTER DELETE ON ckb_transactions -FOR EACH ROW EXECUTE PROCEDURE decrease_ckb_transactions_count(); - } - - execute(raw_sql) - - execute <<-SQL - BEGIN WORK; - lock table ckb_transactions in SHARE ROW EXCLUSIVE MODE; - insert into counters - (name, value, created_at, updated_at) - values ('ckb_transactions', (select count(*) from ckb_transactions), now(), now()) - ; - COMMIT WORK; - SQL - end -end diff --git a/db/migrate/20230210124237_change_block_cycles.rb b/db/migrate/20230210124237_change_block_cycles.rb deleted file mode 100644 index dc9d310bf..000000000 --- a/db/migrate/20230210124237_change_block_cycles.rb +++ /dev/null @@ -1,6 +0,0 @@ -class ChangeBlockCycles < ActiveRecord::Migration[7.0] - def change - change_column :blocks, :cycles, :bigint - change_column :epoch_statistics, :max_block_cycles, :bigint - end -end diff --git a/db/migrate/20230211062045_create_cell_dependencies.rb b/db/migrate/20230211062045_create_cell_dependencies.rb deleted file mode 100644 index 538155814..000000000 --- a/db/migrate/20230211062045_create_cell_dependencies.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateCellDependencies < ActiveRecord::Migration[7.0] - def change - create_table :cell_dependencies do |t| - t.bigint :contract_id - t.bigint :ckb_transaction_id - t.integer :dep_type - t.bigint :contract_cell_id - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20230216084358_create_referring_cells.rb b/db/migrate/20230216084358_create_referring_cells.rb deleted file mode 100644 index 9b7b48149..000000000 --- a/db/migrate/20230216084358_create_referring_cells.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateReferringCells < ActiveRecord::Migration[7.0] - def change - create_table :referring_cells do |t| - t.bigint :cell_output_id - t.bigint :contract_id - t.bigint :ckb_transaction_id - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20230217064540_create_address_dao_transactions.rb b/db/migrate/20230217064540_create_address_dao_transactions.rb deleted file mode 100644 index 812ac7988..000000000 --- a/db/migrate/20230217064540_create_address_dao_transactions.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateAddressDaoTransactions < ActiveRecord::Migration[7.0] - def change - create_table :address_dao_transactions, id: false do |t| - t.bigint :ckb_transaction_id, index: true - t.bigint :address_id - end - add_index :address_dao_transactions, [:address_id, :ckb_transaction_id], unique: true, name: "address_dao_tx_alt_pk" - end -end diff --git a/db/migrate/20230218154437_add_script_id_to_cell_dependencies.rb b/db/migrate/20230218154437_add_script_id_to_cell_dependencies.rb deleted file mode 100644 index 6330ea531..000000000 --- a/db/migrate/20230218154437_add_script_id_to_cell_dependencies.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddScriptIdToCellDependencies < ActiveRecord::Migration[7.0] - def change - add_column :cell_dependencies, :script_id, :bigint - - end -end diff --git a/db/migrate/20230220013604_create_script_transactions.rb b/db/migrate/20230220013604_create_script_transactions.rb deleted file mode 100644 index e42eef308..000000000 --- a/db/migrate/20230220013604_create_script_transactions.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateScriptTransactions < ActiveRecord::Migration[7.0] - def change - create_table :script_transactions do |t| - t.bigint :script_id - t.bigint :ckb_transaction_id - - t.timestamps null:false - end - - add_index :script_transactions, :script_id - add_index :script_transactions, :ckb_transaction_id - end -end diff --git a/db/migrate/20230220060922_add_indexes_to_scripts_and_cell_dependenices_and_deployed_cells.rb b/db/migrate/20230220060922_add_indexes_to_scripts_and_cell_dependenices_and_deployed_cells.rb deleted file mode 100644 index 12af13fed..000000000 --- a/db/migrate/20230220060922_add_indexes_to_scripts_and_cell_dependenices_and_deployed_cells.rb +++ /dev/null @@ -1,10 +0,0 @@ -class AddIndexesToScriptsAndCellDependenicesAndDeployedCells < ActiveRecord::Migration[7.0] - def change - add_index :scripts, :contract_id - add_index :cell_dependencies, :contract_id - add_index :cell_dependencies, :script_id - add_index :cell_dependencies, :contract_cell_id - add_index :deployed_cells, :cell_output_id - add_index :deployed_cells, :contract_id - end -end diff --git a/db/migrate/20230228114330_create_address_udt_transactions.rb b/db/migrate/20230228114330_create_address_udt_transactions.rb deleted file mode 100644 index e4140068e..000000000 --- a/db/migrate/20230228114330_create_address_udt_transactions.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateAddressUdtTransactions < ActiveRecord::Migration[7.0] - def change - create_table :address_udt_transactions, id: false do |t| - t.bigint :ckb_transaction_id, index: true - t.bigint :address_id - end - add_index :address_udt_transactions, [:address_id, :ckb_transaction_id], unique: true, name: "address_udt_tx_alt_pk" - end -end diff --git a/db/migrate/20230306142312_create_block_transaction.rb b/db/migrate/20230306142312_create_block_transaction.rb deleted file mode 100644 index 4dc1e9621..000000000 --- a/db/migrate/20230306142312_create_block_transaction.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateBlockTransaction < ActiveRecord::Migration[7.0] - def change - create_table :block_transactions do |t| - t.references :block, foreign_key: { on_delete: :cascade } - t.references :ckb_transaction, index: true, foreign_key: { on_delete: :cascade } - t.integer :tx_index, null: false, default: 0 - t.index [:block_id, :ckb_transaction_id], name: "block_tx_alt_pk", unique: true - t.index [:block_id, :tx_index], name: "block_tx_index", unique: true - end - end -end diff --git a/db/migrate/20230307073134_add_tx_status_to_ckb_transatction.rb b/db/migrate/20230307073134_add_tx_status_to_ckb_transatction.rb deleted file mode 100644 index 5ef4afe01..000000000 --- a/db/migrate/20230307073134_add_tx_status_to_ckb_transatction.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddTxStatusToCkbTransatction < ActiveRecord::Migration[7.0] - def change - add_column :ckb_transactions, :tx_status, :integer, default: 2, null: false - end -end diff --git a/db/migrate/20230317081407_add_verified_value_to_contracts.rb b/db/migrate/20230317081407_add_verified_value_to_contracts.rb deleted file mode 100644 index 4cc1f1d25..000000000 --- a/db/migrate/20230317081407_add_verified_value_to_contracts.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddVerifiedValueToContracts < ActiveRecord::Migration[7.0] - def change - Contract.update_all verified: true - end -end diff --git a/db/migrate/20230319152819_create_unique_index_on_script_transactions.rb b/db/migrate/20230319152819_create_unique_index_on_script_transactions.rb deleted file mode 100644 index f2bf6fdf5..000000000 --- a/db/migrate/20230319152819_create_unique_index_on_script_transactions.rb +++ /dev/null @@ -1,7 +0,0 @@ -class CreateUniqueIndexOnScriptTransactions < ActiveRecord::Migration[7.0] - def change - add_index :script_transactions, [:ckb_transaction_id, :script_id], unique: true - remove_column :script_transactions, :created_at - remove_column :script_transactions, :updated_at - end -end diff --git a/db/migrate/20230319160108_change_script_transactions_columns_to_not_null.rb b/db/migrate/20230319160108_change_script_transactions_columns_to_not_null.rb deleted file mode 100644 index d08c93a6d..000000000 --- a/db/migrate/20230319160108_change_script_transactions_columns_to_not_null.rb +++ /dev/null @@ -1,6 +0,0 @@ -class ChangeScriptTransactionsColumnsToNotNull < ActiveRecord::Migration[7.0] - def change - change_column_null :script_transactions, :script_id, false - change_column_null :script_transactions, :ckb_transaction_id, false - end -end diff --git a/db/migrate/20230319164714_change_cell_dependency_columns.rb b/db/migrate/20230319164714_change_cell_dependency_columns.rb deleted file mode 100644 index 7b7090c25..000000000 --- a/db/migrate/20230319164714_change_cell_dependency_columns.rb +++ /dev/null @@ -1,16 +0,0 @@ -class ChangeCellDependencyColumns < ActiveRecord::Migration[7.0] - def change - change_column_null :cell_dependencies, :contract_cell_id, false - change_column_null :cell_dependencies, :ckb_transaction_id, false - - execute <<~SQL - DELETE FROM cell_dependencies where id in( - SELECT id - from (SELECT id, - ROW_NUMBER() OVER( PARTITION BY contract_cell_id, ckb_transaction_id - ORDER BY id) as row_num from cell_dependencies) t - WHERE t.row_num > 1 ) - SQL - add_index :cell_dependencies, [:ckb_transaction_id, :contract_cell_id], unique: true, name: "cell_deps_tx_cell_idx" - end -end diff --git a/db/migrate/20230320062211_add_deprecated_to_contracts.rb b/db/migrate/20230320062211_add_deprecated_to_contracts.rb deleted file mode 100644 index c3e709e66..000000000 --- a/db/migrate/20230320062211_add_deprecated_to_contracts.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddDeprecatedToContracts < ActiveRecord::Migration[7.0] - def change - add_column :contracts, :deprecated, :boolean, defalt: false - add_index :contracts, :deprecated - end -end diff --git a/db/migrate/20230320075334_remove_timestamp_from_cell_dependency.rb b/db/migrate/20230320075334_remove_timestamp_from_cell_dependency.rb deleted file mode 100644 index 44fe2ce77..000000000 --- a/db/migrate/20230320075334_remove_timestamp_from_cell_dependency.rb +++ /dev/null @@ -1,6 +0,0 @@ -class RemoveTimestampFromCellDependency < ActiveRecord::Migration[7.0] - def change - remove_column :cell_dependencies, :created_at - remove_column :cell_dependencies, :updated_at - end -end diff --git a/db/migrate/20230320151216_add_combined_index_for_deployed_cells.rb b/db/migrate/20230320151216_add_combined_index_for_deployed_cells.rb deleted file mode 100644 index 092c73792..000000000 --- a/db/migrate/20230320151216_add_combined_index_for_deployed_cells.rb +++ /dev/null @@ -1,11 +0,0 @@ -class AddCombinedIndexForDeployedCells < ActiveRecord::Migration[7.0] - def change - change_column_null :deployed_cells, :cell_output_id, false - change_column_null :deployed_cells, :contract_id, false - remove_index :deployed_cells, :contract_id rescue nil - remove_index :deployed_cells, :cell_output_id rescue nil - DeployedCell.delete_all - add_index :deployed_cells, [:contract_id, :cell_output_id], unique: true - add_index :deployed_cells, :cell_output_id, unique: true - end -end diff --git a/db/migrate/20230320153418_add_script_index_for_lock_script.rb b/db/migrate/20230320153418_add_script_index_for_lock_script.rb deleted file mode 100644 index 080a679e4..000000000 --- a/db/migrate/20230320153418_add_script_index_for_lock_script.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddScriptIndexForLockScript < ActiveRecord::Migration[7.0] - def change - add_index :lock_scripts, :script_id - add_index :type_scripts, :script_id - end -end diff --git a/db/migrate/20230321122734_add_data_hash_to_cell_output.rb b/db/migrate/20230321122734_add_data_hash_to_cell_output.rb deleted file mode 100644 index c41b3230d..000000000 --- a/db/migrate/20230321122734_add_data_hash_to_cell_output.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddDataHashToCellOutput < ActiveRecord::Migration[7.0] - def change - add_column :cell_outputs, :data_hash, :binary - add_index :cell_outputs, :data_hash, using: :hash - end -end diff --git a/db/migrate/20230328134010_create_tigger_for_syncing_pending_tx.rb b/db/migrate/20230328134010_create_tigger_for_syncing_pending_tx.rb deleted file mode 100644 index cdc876263..000000000 --- a/db/migrate/20230328134010_create_tigger_for_syncing_pending_tx.rb +++ /dev/null @@ -1,93 +0,0 @@ -class CreateTiggerForSyncingPendingTx < ActiveRecord::Migration[7.0] - def self.up - execute <<~SQL - CREATE OR REPLACE FUNCTION insert_into_ckb_transactions() - RETURNS TRIGGER AS $$ - DECLARE - header_deps_size integer; - i integer; - header_hash bytea; - transaction_id bigint; - w text; - out_point jsonb; - cell_output_record record; - BEGIN - INSERT INTO ckb_transactions - ( - tx_status, tx_hash, - bytes, cycles, version, - transaction_fee, created_at, updated_at - ) - VALUES - (NEW.tx_status, NEW.tx_hash, - NEW.tx_size, NEW.cycles, COALESCE(NEW.version, 0), - NEW.transaction_fee, NOW(), NOW() - ) - RETURNING id into transaction_id; - - -- insert witnesses - i := 0; - for w in - select jsonb_array_elements_text(NEW.witnesses) - loop - INSERT INTO witnesses (ckb_transaction_id, index, data) - values - (transaction_id, i, (E'\\x' || substring(w from 3))::bytea); - i := i+1; - end loop; - - -- insert header_deps - i := 0; - for w in - select jsonb_array_elements_text(NEW.header_deps) - loop - INSERT INTO header_dependencies - (ckb_transaction_id, header_hash, index) - values - (transaction_id, (E'\\x' || substring(w from 3))::bytea, i); - end loop; - - -- insert cell_deps - for out_point in - select jsonb_array_elements(NEW.cell_deps) - loop - SELECT id, tx_hash, cell_index - INTO cell_output_record - FROM cell_outputs - WHERE tx_hash = (E'\\x' || substring((out_point->'out_point'->>'tx_hash') from 3))::bytea - AND cell_index = (out_point->'out_point'->>'index')::integer; - - IF FOUND THEN - insert into cell_dependencies - (ckb_transaction_id, contract_cell_id, dep_type, implicit) - values( - transaction_id, cell_output_record.id, - CASE WHEN out_point->>'dep_type' = 'code' THEN 0 - WHEN out_point->>'dep_type' = 'dep_group' THEN 1 - ELSE NULL - END, false - ); - END IF; - end loop; - - RETURN NEW; - END; - $$ LANGUAGE plpgsql; - SQL - - execute <<~SQL - CREATE TRIGGER insert_ckb_transactions - AFTER INSERT ON pool_transaction_entries - FOR EACH ROW - EXECUTE FUNCTION insert_into_ckb_transactions(); - SQL - end - - def self.down - execute <<-SQL - DROP TRIGGER insert_ckb_transactions ON pool_transaction_entries - SQL - - execute "DROP FUNCTION insert_into_ckb_transactions()" - end -end diff --git a/db/migrate/20230330112855_create_new_partitioned_ckb_transaction.rb b/db/migrate/20230330112855_create_new_partitioned_ckb_transaction.rb deleted file mode 100644 index 4834ace51..000000000 --- a/db/migrate/20230330112855_create_new_partitioned_ckb_transaction.rb +++ /dev/null @@ -1,58 +0,0 @@ -class CreateNewPartitionedCkbTransaction < ActiveRecord::Migration[7.0] - def up - execute <<~SQL - CREATE TABLE partitioned_ckb_transactions ( - id bigserial NOT NULL, - tx_hash bytea, - block_id bigint, - block_number bigint, - block_timestamp bigint, - tx_status integer DEFAULT 2 NOT NULL, - version integer DEFAULT 0 NOT NULL, - is_cellbase boolean DEFAULT false, - transaction_fee bigint, - created_at timestamp without time zone DEFAULT now() NOT NULL, - updated_at timestamp without time zone DEFAULT now() NOT NULL, - live_cell_changes integer, - capacity_involved numeric(30,0), - tags character varying[] DEFAULT '{}'::character varying[], - bytes bigint DEFAULT 0, - cycles bigint, - confirmation_time integer, - primary key (id, tx_status) - ) PARTITION BY LIST (tx_status); - SQL - execute <<-SQL - CREATE TABLE ckb_transactions_pending - PARTITION OF partitioned_ckb_transactions - FOR VALUES IN (0) - SQL - execute <<-SQL - CREATE TABLE ckb_transactions_committed - PARTITION OF partitioned_ckb_transactions - FOR VALUES IN (2) - SQL - execute <<-SQL - CREATE TABLE ckb_transactions_proposed - PARTITION OF partitioned_ckb_transactions - FOR VALUES IN (1) - SQL - execute <<-SQL - CREATE TABLE ckb_transactions_rejected - PARTITION OF partitioned_ckb_transactions - FOR VALUES IN (3) - SQL - add_index :partitioned_ckb_transactions, :tx_hash, using: :hash - add_index :partitioned_ckb_transactions, [:block_id, :block_timestamp], name: :idx_ckb_txs_for_blocks - add_index :partitioned_ckb_transactions, [:block_timestamp, :id], order: { block_timestamp: "DESC NULLS LAST" }, name: :idx_ckb_txs_timestamp - add_index :partitioned_ckb_transactions, :tags, using: :gin - execute <<-SQL - alter table partitioned_ckb_transactions - add constraint ckb_tx_uni_tx_hash unique(tx_status, tx_hash) - SQL - end - - def down - drop_table :partitioned_ckb_transactions - end -end diff --git a/db/migrate/20230330134854_add_implicit_to_cell_dependency.rb b/db/migrate/20230330134854_add_implicit_to_cell_dependency.rb deleted file mode 100644 index f0d3e361a..000000000 --- a/db/migrate/20230330134854_add_implicit_to_cell_dependency.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddImplicitToCellDependency < ActiveRecord::Migration[7.0] - def change - add_column :cell_dependencies, :implicit, :boolean, default: true, null: false - # Ex:- add_column("admin_users", "username", :string, :limit =>25, :after => "email") - end -end diff --git a/db/migrate/20230330135137_refresh_cell_dependency_implicit.rb b/db/migrate/20230330135137_refresh_cell_dependency_implicit.rb deleted file mode 100644 index 838aff7e2..000000000 --- a/db/migrate/20230330135137_refresh_cell_dependency_implicit.rb +++ /dev/null @@ -1,44 +0,0 @@ -class RefreshCellDependencyImplicit < ActiveRecord::Migration[7.0] - def up - execute <<~SQL - CREATE OR REPLACE FUNCTION update_cell_dependencies_implicit() - RETURNS VOID AS $$ - DECLARE - cur CURSOR FOR SELECT id, cell_deps FROM ckb_transactions; - transaction_id bigint; - cell_deps jsonb; - out_point jsonb; - cell_output_record record; - BEGIN - OPEN cur; - LOOP - FETCH cur INTO transaction_id, cell_deps; - EXIT WHEN NOT FOUND; - - FOR out_point IN - SELECT jsonb_array_elements(cell_deps) - LOOP - SELECT id, tx_hash, cell_index - INTO cell_output_record - FROM cell_outputs - WHERE tx_hash = (E'\\x' || substring((out_point->'out_point'->>'tx_hash') from 3))::bytea - AND cell_index = (out_point->'out_point'->>'index')::integer; - - IF FOUND THEN - UPDATE cell_dependencies - SET implicit = false - WHERE ckb_transaction_id = transaction_id - AND contract_cell_id = cell_output_record.id; - END IF; - END LOOP; - END LOOP; - CLOSE cur; - END; - $$ LANGUAGE plpgsql; - SQL - end - - def down - execute "DROP FUNCTION update_cell_dependencies_implicit();" - end -end diff --git a/db/migrate/20230330155253_create_header_dependencies.rb b/db/migrate/20230330155253_create_header_dependencies.rb deleted file mode 100644 index 423ee2373..000000000 --- a/db/migrate/20230330155253_create_header_dependencies.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateHeaderDependencies < ActiveRecord::Migration[7.0] - def change - create_table :header_dependencies do |t| - t.binary :header_hash, null: false - t.references :ckb_transaction, null: false, foreign_key: true - t.integer :index, null: false - end - add_index :header_dependencies, [:ckb_transaction_id, :index], unique: true - end -end diff --git a/db/migrate/20230330165609_create_witnesses.rb b/db/migrate/20230330165609_create_witnesses.rb deleted file mode 100644 index 6ff998d3b..000000000 --- a/db/migrate/20230330165609_create_witnesses.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateWitnesses < ActiveRecord::Migration[7.0] - def change - create_table :witnesses do |t| - t.binary :data, null: false - t.references :ckb_transaction, null: false, foreign_key: true - t.integer :index, null: false - end - - add_index :witnesses, [:ckb_transaction_id, :index], unique: true - end -end diff --git a/db/migrate/20230331052851_change_global_statistic.rb b/db/migrate/20230331052851_change_global_statistic.rb deleted file mode 100644 index ca15f4c89..000000000 --- a/db/migrate/20230331052851_change_global_statistic.rb +++ /dev/null @@ -1,13 +0,0 @@ -class ChangeGlobalStatistic < ActiveRecord::Migration[7.0] - def change - add_index :global_statistics, :name, unique: true - reversible do |dir| - dir.up do - change_column :global_statistics, :value, :bigint - end - dir.down do - change_column :global_statistics, :value, :integer - end - end - end -end diff --git a/db/migrate/20230331060239_change_global_statistic_triggers.rb b/db/migrate/20230331060239_change_global_statistic_triggers.rb deleted file mode 100644 index 2837556e4..000000000 --- a/db/migrate/20230331060239_change_global_statistic_triggers.rb +++ /dev/null @@ -1,57 +0,0 @@ -class ChangeGlobalStatisticTriggers < ActiveRecord::Migration[7.0] - def change - execute <<~SQL - insert into global_statistics(name, value, created_at, updated_at) - values - ('pending_transactions', 0, now(), now()), - ('committed_transactions', 0, now(), now()) - on conflict do nothing; - SQL - execute <<~SQL - CREATE or replace FUNCTION increase_ckb_transactions_count() - RETURNS TRIGGER AS - $$begin - - UPDATE global_statistics SET value = value + 1 WHERE name = 'ckb_transactions'; - if new.tx_status = 0 then - update global_statistics SET value = value + 1 where name = 'pending_transactions'; - end if; - if new.tx_status = 2 then - update global_statistics SET value = value + 1 where name = 'committed_transactions'; - end if; - RETURN NEW; - end;$$ - LANGUAGE PLPGSQL VOLATILE; - SQL - - execute <<~SQL - CREATE or replace FUNCTION update_ckb_transactions_count() - RETURNS TRIGGER AS - $$begin - if new.tx_status = 0 then - update global_statistics SET value = value + 1 where name = 'pending_transactions'; - end if; - if new.tx_status = 2 then - update global_statistics SET value = value + 1 where name = 'committed_transactions'; - end if; - RETURN NEW; - end;$$ - LANGUAGE PLPGSQL VOLATILE; - SQL - - execute <<~SQL - CREATE OR REPLACE FUNCTION decrease_ckb_transactions_count() RETURNS TRIGGER AS - $$begin - UPDATE global_statistics SET value = value - 1 WHERE name = 'ckb_transactions'; - if new.tx_status = 0 then - update global_statistics SET value = value - 1 where name = 'pending_transactions'; - end if; - if new.tx_status = 2 then - update global_statistics SET value = value - 1 where name = 'committed_transactions'; - end if; - RETURN NEW; - end;$$ - LANGUAGE PLPGSQL VOLATILE; - SQL - end -end diff --git a/db/migrate/20230331090020_change_column_types_from_decimal_to_bigint.rb b/db/migrate/20230331090020_change_column_types_from_decimal_to_bigint.rb deleted file mode 100644 index eef4b2490..000000000 --- a/db/migrate/20230331090020_change_column_types_from_decimal_to_bigint.rb +++ /dev/null @@ -1,91 +0,0 @@ -class ChangeColumnTypesFromDecimalToBigint < ActiveRecord::Migration[7.0] - def self.up - # if we don't drop this view, we cannot modify the type of timestamp column in blocks table - execute "DROP MATERIALIZED VIEW if exists average_block_time_by_hour CASCADE" - - change_table(:addresses, bulk: true) do |t| - t.change :cell_consumed, :bigint - t.change :ckb_transactions_count, :bigint - t.change :block_timestamp, :bigint - t.change :live_cells_count, :bigint - t.change :average_deposit_time, :bigint - t.change :dao_transactions_count, :bigint - end - change_table(:blocks, bulk: true) do |t| - t.change :number, :bigint - t.change :timestamp, :bigint - t.change :cell_consumed, :bigint - t.change :ckb_transactions_count, :bigint - t.change :epoch, :bigint - - t.change :block_size, :bigint - t.change :median_timestamp, :bigint - t.change :block_time, :bigint - end - change_table(:block_statistics, bulk: true) do |t| - t.change :block_number, :bigint - t.change :epoch_number, :bigint - end - - change_column :dao_events, :block_id, :bigint - - change_table :epoch_statistics, bulk: true do |t| - t.change :epoch_number, :bigint - t.change :epoch_time, :bigint - end - - change_table :forked_blocks, bulk: true do |t| - t.change :number, :bigint - t.change :timestamp, :bigint - t.change :epoch, :bigint - end - - change_table :uncle_blocks, bulk: true do |t| - t.change :number, :bigint - t.change :timestamp, :bigint - t.change :epoch, :bigint - end - - change_table :udts, bulk: true do |t| - t.change :addresses_count, :bigint - t.change :block_timestamp, :bigint - t.change :ckb_transactions_count, :bigint - end - end - - def self.down - change_column :addresses, :cell_consumed, :decimal, precision: 30, scale: 0 - change_column :addresses, :ckb_transactions_count, :decimal, precision: 30, scale: 0 - change_column :addresses, :block_timestamp, :decimal, precision: 30, scale: 0 - change_column :addresses, :live_cells_count, :decimal, precision: 30, scale: 0 - change_column :addresses, :average_deposit_time, :decimal, precision: 30, scale: 0 - change_column :addresses, :dao_transactions_count, :decimal, precision: 30, scale: 0 - - change_column :blocks, :number, :decimal, precision: 30, scale: 0 - change_column :blocks, :cell_consumed, :decimal, precision: 30, scale: 0 - change_column :blocks, :ckb_transactions_count, :decimal, precision: 30, scale: 0 - change_column :blocks, :epoch, :decimal, precision: 30, scale: 0 - change_column :blocks, :block_size, :decimal, precision: 30, scale: 0 - change_column :blocks, :median_timestamp, :decimal, precision: 30, scale: 0 - - change_column :block_statistics, :block_number, :decimal, precision: 30, scale: 0 - change_column :block_statistics, :epoch_number, :decimal, precision: 30, scale: 0 - - change_column :dao_events, :block_id, :decimal, precision: 30, scale: 0 - - change_column :epoch_statistics, :epoch_number, :decimal, precision: 30, scale: 0 - change_column :epoch_statistics, :epoch_time, :decimal, precision: 30, scale: 0 - - change_column :forked_blocks, :number, :decimal, precision: 30, scale: 0 - change_column :forked_blocks, :timestamp, :decimal, precision: 30, scale: 0 - change_column :forked_blocks, :epoch, :decimal, precision: 30, scale: 0 - - change_column :uncle_blocks, :number, :decimal, precision: 30, scale: 0 - change_column :uncle_blocks, :timestamp, :decimal, precision: 30, scale: 0 - change_column :uncle_blocks, :epoch, :decimal, precision: 30, scale: 0 - - change_column :udts, :addresses_count, :decimal, precision: 30, scale: 0 - change_column :udts, :block_timestamp, :decimal, precision: 30, scale: 0 - change_column :udts, :ckb_transactions_count, :decimal, precision: 30, scale: 0 - end -end diff --git a/db/migrate/20230331151334_migrate_ckb_transactions_to_partition.rb b/db/migrate/20230331151334_migrate_ckb_transactions_to_partition.rb deleted file mode 100644 index e19804618..000000000 --- a/db/migrate/20230331151334_migrate_ckb_transactions_to_partition.rb +++ /dev/null @@ -1,21 +0,0 @@ -class MigrateCkbTransactionsToPartition < ActiveRecord::Migration[7.0] - disable_ddl_transaction! - - def change - # insert ckb_transactions to partition - execute <<~SQL - insert into partitioned_ckb_transactions( - id, tx_hash, tx_status, block_id, block_number, - block_timestamp, version, is_cellbase, transaction_fee, - created_at, updated_at, - live_cell_changes, capacity_involved, tags, - bytes, cycles, confirmation_time) - SELECT id, tx_hash, 2, block_id, block_number, - block_timestamp, version, is_cellbase, transaction_fee, - created_at, updated_at, - live_cell_changes, capacity_involved, tags, - bytes, cycles, confirmation_time - FROM ckb_transactions; - SQL - end -end diff --git a/db/migrate/20230331151335_migrate_header_deps.rb b/db/migrate/20230331151335_migrate_header_deps.rb deleted file mode 100644 index ba868925d..000000000 --- a/db/migrate/20230331151335_migrate_header_deps.rb +++ /dev/null @@ -1,7 +0,0 @@ -class MigrateHeaderDeps < ActiveRecord::Migration[7.0] - disable_ddl_transaction! - - def change - HeaderDependency.migrate_old - end -end diff --git a/db/migrate/20230331151336_clean_cell_input.rb b/db/migrate/20230331151336_clean_cell_input.rb deleted file mode 100644 index 08f9f2210..000000000 --- a/db/migrate/20230331151336_clean_cell_input.rb +++ /dev/null @@ -1,35 +0,0 @@ -class CleanCellInput < ActiveRecord::Migration[7.0] - def up - execute <<~SQL - CREATE OR REPLACE PROCEDURE update_cell_inputs() LANGUAGE plpgsql AS $$ - DECLARE - input_id BIGINT; - input_output_id BIGINT; - input_previous_output JSONB; - input_tx_hash BYTEA; - input_cell_index BIGINT; - output_id BIGINT; - BEGIN - FOR input_id, input_previous_output, input_output_id IN - SELECT ci.id, ci.previous_output, ci.previous_cell_output_id - FROM cell_inputs ci - WHERE ci.previous_cell_output_id IS NULL AND ci.previous_output->>'tx_hash' <> '0x0000000000000000000000000000000000000000000000000000000000000000' - LOOP - input_tx_hash := decode(input_previous_output->>'tx_hash', 'hex'); - input_cell_index := input_previous_output->>'index'; - - SELECT id INTO output_id FROM cell_outputs WHERE tx_hash = input_tx_hash AND cell_index = input_cell_index; - - IF output_id IS NOT NULL THEN - UPDATE cell_inputs SET previous_cell_output_id = output_id WHERE id = input_id; - END IF; - END LOOP; - END; - $$; - SQL - end - - def down - execute "drop PROCEDURE update_cell_inputs" - end -end diff --git a/db/migrate/20230401012010_remove_ckb_transaction_foreign_keys.rb b/db/migrate/20230401012010_remove_ckb_transaction_foreign_keys.rb deleted file mode 100644 index b40a31800..000000000 --- a/db/migrate/20230401012010_remove_ckb_transaction_foreign_keys.rb +++ /dev/null @@ -1,8 +0,0 @@ -class RemoveCkbTransactionForeignKeys < ActiveRecord::Migration[7.0] - def change - remove_foreign_key :udt_transactions, :ckb_transactions - remove_foreign_key :block_transactions, :ckb_transactions - remove_foreign_key :header_dependencies, :ckb_transactions - remove_foreign_key :witnesses, :ckb_transactions - end -end diff --git a/db/migrate/20230401033240_rename_ckb_transactions.rb b/db/migrate/20230401033240_rename_ckb_transactions.rb deleted file mode 100644 index 13d896c33..000000000 --- a/db/migrate/20230401033240_rename_ckb_transactions.rb +++ /dev/null @@ -1,6 +0,0 @@ -class RenameCkbTransactions < ActiveRecord::Migration[7.0] - def change - rename_table :ckb_transactions, :old_ckb_transactions - rename_table :partitioned_ckb_transactions, :ckb_transactions - end -end diff --git a/db/migrate/20230402125000_recreate_ckb_transaction_triggers.rb b/db/migrate/20230402125000_recreate_ckb_transaction_triggers.rb deleted file mode 100644 index a3182dfc0..000000000 --- a/db/migrate/20230402125000_recreate_ckb_transaction_triggers.rb +++ /dev/null @@ -1,18 +0,0 @@ -class RecreateCkbTransactionTriggers < ActiveRecord::Migration[7.0] - def change - execute <<~SQL - - CREATE TRIGGER after_insert_update_ckb_transactions_count - AFTER INSERT ON ckb_transactions - FOR EACH ROW EXECUTE PROCEDURE increase_ckb_transactions_count(); - - CREATE TRIGGER after_update_ckb_transactions_count - AFTER UPDATE ON ckb_transactions - FOR EACH ROW EXECUTE PROCEDURE update_ckb_transactions_count(); - - CREATE TRIGGER after_delete_update_ckb_transactions_count - AFTER DELETE ON ckb_transactions - FOR EACH ROW EXECUTE PROCEDURE decrease_ckb_transactions_count(); - SQL - end -end diff --git a/db/migrate/20230403052005_reset_ckb_transaction_auto_increment_value.rb b/db/migrate/20230403052005_reset_ckb_transaction_auto_increment_value.rb deleted file mode 100644 index b6f811701..000000000 --- a/db/migrate/20230403052005_reset_ckb_transaction_auto_increment_value.rb +++ /dev/null @@ -1,8 +0,0 @@ -class ResetCkbTransactionAutoIncrementValue < ActiveRecord::Migration[7.0] - def change - max_ckb_tx_id = CkbTransaction.maximum(:id) - if max_ckb_tx_id - ActiveRecord::Base.connection.execute("ALTER SEQUENCE ckb_transactions_id_seq RESTART WITH #{max_ckb_tx_id + 1}") - end - end -end diff --git a/db/migrate/20230403154742_expand_transaction_int_columns.rb b/db/migrate/20230403154742_expand_transaction_int_columns.rb deleted file mode 100644 index 12483ab97..000000000 --- a/db/migrate/20230403154742_expand_transaction_int_columns.rb +++ /dev/null @@ -1,15 +0,0 @@ -class ExpandTransactionIntColumns < ActiveRecord::Migration[7.0] - def up - change_table :ckb_transactions, bulk: true do |t| - t.change :bytes, :bigint - t.change :cycles, :bigint - end - end - - def down - change_table :ckb_transactions, bulk: true do |t| - t.change :bytes, :integer - t.change :cycles, :integer - end - end -end diff --git a/db/migrate/20230404072229_expand_cycles_in_forked_block.rb b/db/migrate/20230404072229_expand_cycles_in_forked_block.rb deleted file mode 100644 index 039f5fc1e..000000000 --- a/db/migrate/20230404072229_expand_cycles_in_forked_block.rb +++ /dev/null @@ -1,11 +0,0 @@ -class ExpandCyclesInForkedBlock < ActiveRecord::Migration[7.0] - def up - change_column :forked_blocks, :cycles, :bigint - # Ex:- change_column("admin_users", "email", :string, :limit =>25) - end - - def down - change_column :forked_blocks, :cycles, :integer - # Ex:- change_column("admin_users", "email", :string, :limit =>25) - end -end diff --git a/db/migrate/20230404151647_recreate_average_block_time_views.rb b/db/migrate/20230404151647_recreate_average_block_time_views.rb deleted file mode 100644 index 752dd6911..000000000 --- a/db/migrate/20230404151647_recreate_average_block_time_views.rb +++ /dev/null @@ -1,31 +0,0 @@ -class RecreateAverageBlockTimeViews < ActiveRecord::Migration[7.0] - def self.up - execute <<~SQL - CREATE MATERIALIZED VIEW IF NOT EXISTS average_block_time_by_hour - AS - SELECT (blocks."timestamp" / 3600000)::bigint AS hour, - avg(blocks.block_time) AS avg_block_time_per_hour - FROM blocks - GROUP BY (blocks."timestamp" / 3600000)::bigint - WITH NO DATA; - SQL - - execute <<~SQL - CREATE MATERIALIZED VIEW IF NOT EXISTS rolling_avg_block_time - TABLESPACE pg_default - AS - SELECT (average_block_time_by_hour.hour * 3600)::bigint as timestamp, - avg(average_block_time_by_hour.avg_block_time_per_hour) OVER (ORDER BY average_block_time_by_hour.hour ROWS BETWEEN 24 PRECEDING AND CURRENT ROW) AS avg_block_time_daily, - avg(average_block_time_by_hour.avg_block_time_per_hour) OVER (ORDER BY average_block_time_by_hour.hour ROWS BETWEEN (7 * 24) PRECEDING AND CURRENT ROW) AS avg_block_time_weekly - FROM average_block_time_by_hour - WITH NO DATA; - SQL - - add_index :average_block_time_by_hour, :hour, unique: true - add_index :rolling_avg_block_time, :timestamp, unique: true - end - - def self.down - execute "DROP MATERIALIZED VIEW IF EXISTS rolling_avg_block_time, average_block_time_by_hour" - end -end diff --git a/db/migrate/20230406003722_create_transaction_address_changes.rb b/db/migrate/20230406003722_create_transaction_address_changes.rb deleted file mode 100644 index 6f557ffb6..000000000 --- a/db/migrate/20230406003722_create_transaction_address_changes.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateTransactionAddressChanges < ActiveRecord::Migration[7.0] - def change - create_table :transaction_address_changes do |t| - t.bigint :ckb_transaction_id, null: false - t.bigint :address_id, null: false - t.string :name, null: false - t.decimal :delta, null: false, default: 0 - t.index :ckb_transaction_id - t.index [:address_id, :ckb_transaction_id, :name], unique: true, name: "tx_address_changes_alt_pk" - end - end -end diff --git a/db/migrate/20230406011556_create_cell_data.rb b/db/migrate/20230406011556_create_cell_data.rb deleted file mode 100644 index 9db6c0698..000000000 --- a/db/migrate/20230406011556_create_cell_data.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateCellData < ActiveRecord::Migration[7.0] - def change - create_table :cell_data, id: false do |t| - t.bigint :cell_output_id, null: false, primary_key: true - t.binary :data, null: false - end - end -end diff --git a/db/migrate/20230412070853_remove_consumed_block_timestamp_default_value.rb b/db/migrate/20230412070853_remove_consumed_block_timestamp_default_value.rb deleted file mode 100644 index 53661d500..000000000 --- a/db/migrate/20230412070853_remove_consumed_block_timestamp_default_value.rb +++ /dev/null @@ -1,12 +0,0 @@ -class RemoveConsumedBlockTimestampDefaultValue < ActiveRecord::Migration[7.0] - def change - change_column_default :cell_outputs, :consumed_block_timestamp, from: 0, to: nil - reversible do |dir| - dir.up do - CellOutput.where.not(consumed_block_timestamp: nil).where(consumed_by_id: nil).update_all(consumed_block_timestamp: nil) - end - dir.down do - end - end - end -end diff --git a/db/migrate/20230415042814_add_index_to_cell_input.rb b/db/migrate/20230415042814_add_index_to_cell_input.rb deleted file mode 100644 index 4b18781ef..000000000 --- a/db/migrate/20230415042814_add_index_to_cell_input.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddIndexToCellInput < ActiveRecord::Migration[7.0] - def change - add_column :cell_inputs, :index, :integer - end -end diff --git a/db/migrate/20230415150143_change_transaction_address_changes.rb b/db/migrate/20230415150143_change_transaction_address_changes.rb deleted file mode 100644 index 0165cf122..000000000 --- a/db/migrate/20230415150143_change_transaction_address_changes.rb +++ /dev/null @@ -1,10 +0,0 @@ -class ChangeTransactionAddressChanges < ActiveRecord::Migration[7.0] - def change - change_table :transaction_address_changes do |t| - t.remove :name, type: :string - t.remove :delta, type: :decimal - t.jsonb :changes, null: false, default: {} - t.index [:address_id, :ckb_transaction_id], unique: true, name: 'tx_address_changes_alt_pk' - end - end -end diff --git a/db/migrate/20230425114436_add_cell_type_index_to_cell_output.rb b/db/migrate/20230425114436_add_cell_type_index_to_cell_output.rb deleted file mode 100644 index 3faf16930..000000000 --- a/db/migrate/20230425114436_add_cell_type_index_to_cell_output.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCellTypeIndexToCellOutput < ActiveRecord::Migration[7.0] - def change - add_index :cell_outputs, :cell_type - end -end diff --git a/db/migrate/20230425162318_create_statistic_infos.rb b/db/migrate/20230425162318_create_statistic_infos.rb deleted file mode 100644 index e0eb43070..000000000 --- a/db/migrate/20230425162318_create_statistic_infos.rb +++ /dev/null @@ -1,16 +0,0 @@ -class CreateStatisticInfos < ActiveRecord::Migration[7.0] - def change - create_table :statistic_infos do |t| - t.bigint :transactions_last_24hrs - t.bigint :transactions_count_per_minute - t.float :average_block_time - t.decimal :hash_rate - t.jsonb :address_balance_ranking - t.jsonb :miner_ranking - t.string :blockchain_info - t.jsonb :last_n_days_transaction_fee_rates - - t.timestamps - end - end -end diff --git a/db/migrate/20230426133543_add_fee_rate_fields_to_statistic_info.rb b/db/migrate/20230426133543_add_fee_rate_fields_to_statistic_info.rb deleted file mode 100644 index 61186fbac..000000000 --- a/db/migrate/20230426133543_add_fee_rate_fields_to_statistic_info.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddFeeRateFieldsToStatisticInfo < ActiveRecord::Migration[7.0] - def change - add_column :statistic_infos, :pending_transaction_fee_rates, :jsonb - add_column :statistic_infos, :transaction_fee_rates, :jsonb - # Ex:- add_column("admin_users", "username", :string, :limit =>25, :after => "email") - end -end diff --git a/db/migrate/20230427025007_remove_generated_by_id_of_cell_output.rb b/db/migrate/20230427025007_remove_generated_by_id_of_cell_output.rb deleted file mode 100644 index cf03e00f5..000000000 --- a/db/migrate/20230427025007_remove_generated_by_id_of_cell_output.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RemoveGeneratedByIdOfCellOutput < ActiveRecord::Migration[7.0] - def change - remove_column :cell_outputs, :generated_by_id, :decimal, precision: 30, scale: 0 - end -end diff --git a/db/migrate/20230504023535_add_h24_ckb_transactions_count_to_udts.rb b/db/migrate/20230504023535_add_h24_ckb_transactions_count_to_udts.rb deleted file mode 100644 index c10a8aa36..000000000 --- a/db/migrate/20230504023535_add_h24_ckb_transactions_count_to_udts.rb +++ /dev/null @@ -1,17 +0,0 @@ -class AddH24CkbTransactionsCountToUdts < ActiveRecord::Migration[7.0] - def up - add_column :udts, :h24_ckb_transactions_count, :bigint, default: 0 - - Udt.all.each do |udt| - h24_ckb_transactions_count = Rails.cache.realize("udt_h24_ckb_transactions_count_#{udt.id}", expires_in: 1.hour) do - udt.ckb_transactions.where("block_timestamp >= ?", CkbUtils.time_in_milliseconds(24.hours.ago)).count - end - - udt.update_columns(h24_ckb_transactions_count: h24_ckb_transactions_count) - end - end - - def down - remove_column :udts, :h24_ckb_transactions_count, :bigint, default: 0 - end -end diff --git a/db/migrate/20230518061651_change_cell_input_previous_output.rb b/db/migrate/20230518061651_change_cell_input_previous_output.rb deleted file mode 100644 index bd9fdc57e..000000000 --- a/db/migrate/20230518061651_change_cell_input_previous_output.rb +++ /dev/null @@ -1,16 +0,0 @@ -class ChangeCellInputPreviousOutput < ActiveRecord::Migration[7.0] - def change - change_table :cell_inputs, bulk: true do |t| - t.binary :previous_tx_hash - t.integer :previous_index - end - execute <<~SQL - UPDATE cell_inputs - SET previous_tx_hash = decode(substring(previous_output ->> 'tx_hash',3), 'hex') , - previous_index = ('x' || lpad(substring(previous_output ->> 'index' from 3), 8, '0'))::bit(32)::int - where previous_cell_output_id is null and previous_output is not null - SQL - add_index :cell_inputs, [:previous_tx_hash, :previous_index] - remove_column :cell_inputs, :previous_output - end -end diff --git a/db/migrate/20230526070328_create_reject_reasons.rb b/db/migrate/20230526070328_create_reject_reasons.rb deleted file mode 100644 index 219865349..000000000 --- a/db/migrate/20230526070328_create_reject_reasons.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateRejectReasons < ActiveRecord::Migration[7.0] - def change - create_table :reject_reasons do |t| - t.bigint :ckb_transaction_id, null: false - t.text :message - end - add_index :reject_reasons, :ckb_transaction_id, unique: true - end -end diff --git a/db/migrate/20230526085258_address_block_snapshot.rb b/db/migrate/20230526085258_address_block_snapshot.rb deleted file mode 100644 index 735fc07cd..000000000 --- a/db/migrate/20230526085258_address_block_snapshot.rb +++ /dev/null @@ -1,12 +0,0 @@ -class AddressBlockSnapshot < ActiveRecord::Migration[7.0] - def change - create_table :address_block_snapshots do |t| - t.belongs_to :address - t.belongs_to :block - t.bigint :block_number - t.jsonb :final_state - - t.index [:block_id, :address_id], unique: true - end - end -end diff --git a/db/migrate/20230526135653_migrate_reject_messages.rb b/db/migrate/20230526135653_migrate_reject_messages.rb deleted file mode 100644 index 952d5fd6a..000000000 --- a/db/migrate/20230526135653_migrate_reject_messages.rb +++ /dev/null @@ -1,19 +0,0 @@ -class MigrateRejectMessages < ActiveRecord::Migration[7.0] - def change - execute <<~SQL - INSERT INTO reject_reasons (ckb_transaction_id, message) - SELECT ckb_transactions.id, pool_transaction_entries.detailed_message - FROM ckb_transactions - JOIN pool_transaction_entries - ON ckb_transactions.tx_hash = pool_transaction_entries.tx_hash - where pool_transaction_entries.tx_status = 3 - SQL - execute <<~SQL - UPDATE ckb_transactions - SET tx_status = pool_transaction_entries.tx_status - FROM pool_transaction_entries - WHERE ckb_transactions.tx_hash = pool_transaction_entries.tx_hash - AND pool_transaction_entries.tx_status = 3 - SQL - end -end diff --git a/db/migrate/20230603124843_copy_cell_data.rb b/db/migrate/20230603124843_copy_cell_data.rb deleted file mode 100644 index f99d8717e..000000000 --- a/db/migrate/20230603124843_copy_cell_data.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CopyCellData < ActiveRecord::Migration[7.0] - disable_ddl_transaction! - def change - i = CellDatum.maximum(:cell_output_id) - CellOutput.where("id>?", i || 0).where("data is not null and length(data) > 2").find_each do |c| - d = c.cell_datum || c.build_cell_datum - d.data = CKB::Utils.hex_to_bin(c[:data]) - d.save validate: false - end - end -end diff --git a/db/migrate/20230622134109_add_unique_constraint_for_cell_output.rb b/db/migrate/20230622134109_add_unique_constraint_for_cell_output.rb deleted file mode 100644 index 63462d326..000000000 --- a/db/migrate/20230622134109_add_unique_constraint_for_cell_output.rb +++ /dev/null @@ -1,8 +0,0 @@ -class AddUniqueConstraintForCellOutput < ActiveRecord::Migration[7.0] - def change - remove_index :cell_outputs, [:tx_hash, :cell_index] - add_index :cell_outputs, [:tx_hash, :cell_index], unique: true - add_index :cell_outputs, [:ckb_transaction_id, :cell_index], unique: true - remove_index :cell_outputs, :ckb_transaction_id - end -end diff --git a/db/migrate/20230622143224_add_missing_index_for_cell_input.rb b/db/migrate/20230622143224_add_missing_index_for_cell_input.rb deleted file mode 100644 index e53de9146..000000000 --- a/db/migrate/20230622143224_add_missing_index_for_cell_input.rb +++ /dev/null @@ -1,65 +0,0 @@ -class AddMissingIndexForCellInput < ActiveRecord::Migration[7.0] - disable_ddl_transaction! - def change - execute <<~SQL - CREATE TABLE IF NOT EXISTS public.cell_inputs_new - ( - id bigint NOT NULL DEFAULT nextval('cell_inputs_id_seq'::regclass), - ckb_transaction_id bigint, - created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL, - previous_cell_output_id bigint, - from_cell_base boolean DEFAULT false, - block_id bigint, - since numeric(30,0) DEFAULT 0.0, - cell_type integer DEFAULT 0, - index integer, - previous_tx_hash bytea, - previous_index integer, - CONSTRAINT cell_inputs_pkey_new PRIMARY KEY (id) - ); - - CREATE INDEX IF NOT EXISTS idx_cell_inputs_on_block_id - ON public.cell_inputs_new USING btree - (block_id ASC NULLS LAST) - TABLESPACE pg_default; - -- Index: index_cell_inputs_on_ckb_transaction_id - - -- DROP INDEX IF EXISTS public.index_cell_inputs_on_ckb_transaction_id; - - CREATE INDEX IF NOT EXISTS idx_cell_inputs_on_ckb_transaction_id - ON public.cell_inputs_new USING btree - (ckb_transaction_id ASC NULLS LAST) - TABLESPACE pg_default; - -- Index: index_cell_inputs_on_previous_cell_output_id - - -- DROP INDEX IF EXISTS public.index_cell_inputs_on_previous_cell_output_id; - - CREATE INDEX IF NOT EXISTS idx_cell_inputs_on_previous_cell_output_id - ON public.cell_inputs_new USING btree - (previous_cell_output_id ASC NULLS LAST) - TABLESPACE pg_default; - -- Index: index_cell_inputs_on_previous_tx_hash_and_previous_index - - -- DROP INDEX IF EXISTS public.index_cell_inputs_on_previous_tx_hash_and_previous_index; - - CREATE INDEX IF NOT EXISTS idx_cell_inputs_on_previous_tx_hash_and_previous_index - ON public.cell_inputs_new USING btree - (previous_tx_hash ASC NULLS LAST, previous_index ASC NULLS LAST) - TABLESPACE pg_default; - SQL - - execute <<-SQL - insert into cell_inputs_new - SELECT id,ckb_transaction_id,created_at,updated_at,previous_cell_output_id,from_cell_base,block_id, - since,cell_type,ROW_NUMBER() OVER (PARTITION BY ckb_transaction_id ORDER BY id) - 1 AS index,previous_tx_hash,previous_index - FROM cell_inputs; - SQL - execute <<-SQL - ALTER TABLE cell_inputs rename to cell_inputs_old; - SQL - execute <<-SQL - alter table cell_inputs_new rename to cell_inputs; - SQL - end -end diff --git a/db/migrate/20230622143339_add_unique_index_for_cell_input.rb b/db/migrate/20230622143339_add_unique_index_for_cell_input.rb deleted file mode 100644 index f2ba93a78..000000000 --- a/db/migrate/20230622143339_add_unique_index_for_cell_input.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddUniqueIndexForCellInput < ActiveRecord::Migration[7.0] - def change - add_index :cell_inputs, [:ckb_transaction_id, :index], unique: true - remove_index :cell_inputs, :ckb_transaction_id - end -end diff --git a/db/migrate/20230630112234_add_uniq_index_to_daily_statistic.rb b/db/migrate/20230630112234_add_uniq_index_to_daily_statistic.rb deleted file mode 100644 index c9b2bf95b..000000000 --- a/db/migrate/20230630112234_add_uniq_index_to_daily_statistic.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddUniqIndexToDailyStatistic < ActiveRecord::Migration[7.0] - def change - remove_index :daily_statistics, :created_at_unixtimestamp - add_index :daily_statistics, :created_at_unixtimestamp, unique: true - end -end diff --git a/db/migrate/20230711040233_add_h24_ckb_transactions_count_to_token_collections.rb b/db/migrate/20230711040233_add_h24_ckb_transactions_count_to_token_collections.rb deleted file mode 100644 index 2b3311212..000000000 --- a/db/migrate/20230711040233_add_h24_ckb_transactions_count_to_token_collections.rb +++ /dev/null @@ -1,21 +0,0 @@ -class AddH24CkbTransactionsCountToTokenCollections < ActiveRecord::Migration[7.0] - def up - add_column :token_collections, :h24_ckb_transactions_count, :bigint, default: 0 - - TokenCollection.find_each do |collection| - h24_ckb_transactions_count = - Rails.cache.realize("collection_h24_ckb_transactions_count_#{collection.id}", expires_in: 1.hour) do - timestamp = CkbUtils.time_in_milliseconds(24.hours.ago) - h24_transfers = collection.transfers.joins(:ckb_transaction).where("ckb_transactions.block_timestamp >= ?", - timestamp) - h24_transfers.distinct.count(:transaction_id) - end - - collection.update_column(:h24_ckb_transactions_count, h24_ckb_transactions_count) - end - end - - def down - remove_column :token_collections, :h24_ckb_transactions_count - end -end diff --git a/db/migrate/20230802015907_change_max_tx_cycles_to_epoch_statistic.rb b/db/migrate/20230802015907_change_max_tx_cycles_to_epoch_statistic.rb deleted file mode 100644 index 2f9762d1d..000000000 --- a/db/migrate/20230802015907_change_max_tx_cycles_to_epoch_statistic.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ChangeMaxTxCyclesToEpochStatistic < ActiveRecord::Migration[7.0] - def change - change_column :epoch_statistics, :max_tx_cycles, :bigint - end -end diff --git a/db/migrate/20230808020637_add_contact_info_to_udts.rb b/db/migrate/20230808020637_add_contact_info_to_udts.rb deleted file mode 100644 index 82b9b38a9..000000000 --- a/db/migrate/20230808020637_add_contact_info_to_udts.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddContactInfoToUdts < ActiveRecord::Migration[7.0] - def change - add_column :udts, :contact_info, :string - end -end diff --git a/db/migrate/20230829061910_add_indexes_to_referring_cells.rb b/db/migrate/20230829061910_add_indexes_to_referring_cells.rb deleted file mode 100644 index a062dfd8b..000000000 --- a/db/migrate/20230829061910_add_indexes_to_referring_cells.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddIndexesToReferringCells < ActiveRecord::Migration[7.0] - def change - add_index :referring_cells, [:contract_id, :cell_output_id], unique: true - add_index :referring_cells, :cell_output_id, unique: true - end -end diff --git a/db/migrate/20230913091025_create_udt_verifications.rb b/db/migrate/20230913091025_create_udt_verifications.rb deleted file mode 100644 index 5441b35b9..000000000 --- a/db/migrate/20230913091025_create_udt_verifications.rb +++ /dev/null @@ -1,14 +0,0 @@ -class CreateUdtVerifications < ActiveRecord::Migration[7.0] - def change - create_table :udt_verifications do |t| - t.integer :token - t.datetime :sent_at - t.inet :last_ip - t.belongs_to :udt - t.integer :udt_type_hash - - t.timestamps - t.index :udt_type_hash, unique: true - end - end -end diff --git a/db/migrate/20230914120928_change_contract_info_to_email_in_udt.rb b/db/migrate/20230914120928_change_contract_info_to_email_in_udt.rb deleted file mode 100644 index 163bcb6f1..000000000 --- a/db/migrate/20230914120928_change_contract_info_to_email_in_udt.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ChangeContractInfoToEmailInUdt < ActiveRecord::Migration[7.0] - def change - rename_column :udts, :contact_info, :email - end -end diff --git a/db/migrate/20230918033957_add_statistics_to_contract.rb b/db/migrate/20230918033957_add_statistics_to_contract.rb deleted file mode 100644 index e78c6eed2..000000000 --- a/db/migrate/20230918033957_add_statistics_to_contract.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddStatisticsToContract < ActiveRecord::Migration[7.0] - def change - add_column :contracts, :ckb_transactions_count, :decimal, precision: 30, default: 0 - add_column :contracts, :deployed_cells_count, :decimal, precision: 30, default: 0 - add_column :contracts, :referring_cells_count, :decimal, precision: 30, default: 0 - add_column :contracts, :total_deployed_cells_capacity, :decimal, precision: 30, default: 0 - add_column :contracts, :total_referring_cells_capacity, :decimal, precision: 30, default: 0 - end -end diff --git a/db/migrate/20231017074221_init.rb b/db/migrate/20231017074221_init.rb new file mode 100644 index 000000000..e783bba59 --- /dev/null +++ b/db/migrate/20231017074221_init.rb @@ -0,0 +1,571 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema[7.0].define(version: 2022_11_15_112050) do + # These are extensions that must be enabled in order to support this database + enable_extension "btree_gin" + enable_extension "plpgsql" + + create_table "account_books", force: :cascade do |t| + t.bigint "address_id" + t.bigint "ckb_transaction_id" + t.index ["address_id", "ckb_transaction_id"], name: "index_account_books_on_address_id_and_ckb_transaction_id", unique: true + t.index ["ckb_transaction_id"], name: "index_account_books_on_ckb_transaction_id" + end + + create_table "addresses", force: :cascade do |t| + t.decimal "balance", precision: 30, default: "0" + t.binary "address_hash" + t.decimal "cell_consumed", precision: 30 + t.decimal "ckb_transactions_count", precision: 30, default: "0" + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false + t.binary "lock_hash" + t.decimal "dao_deposit", precision: 30, default: "0" + t.decimal "interest", precision: 30, default: "0" + t.decimal "block_timestamp", precision: 30 + t.decimal "live_cells_count", precision: 30, default: "0" + t.integer "mined_blocks_count", default: 0 + t.boolean "visible", default: true + t.decimal "average_deposit_time" + t.decimal "unclaimed_compensation", precision: 30 + t.boolean "is_depositor", default: false + t.decimal "dao_transactions_count", precision: 30, default: "0" + t.bigint "lock_script_id" + t.decimal "balance_occupied", precision: 30, default: "0" + t.bigint "address_hash_crc" + t.index ["address_hash_crc"], name: "index_addresses_on_address_hash_crc" + t.index ["is_depositor"], name: "index_addresses_on_is_depositor", where: "(is_depositor = true)" + t.index ["lock_hash"], name: "index_addresses_on_lock_hash", unique: true + end + + create_table "block_propagation_delays", force: :cascade do |t| + t.string "block_hash" + t.integer "created_at_unixtimestamp" + t.jsonb "durations" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["created_at_unixtimestamp"], name: "index_block_propagation_delays_on_created_at_unixtimestamp" + end + + create_table "block_statistics", force: :cascade do |t| + t.string "difficulty" + t.string "hash_rate" + t.string "live_cells_count", default: "0" + t.string "dead_cells_count", default: "0" + t.decimal "block_number", precision: 30 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.decimal "epoch_number", precision: 30 + t.index ["block_number"], name: "index_block_statistics_on_block_number", unique: true + end + + create_table "block_time_statistics", force: :cascade do |t| + t.decimal "stat_timestamp", precision: 30 + t.decimal "avg_block_time_per_hour" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["stat_timestamp"], name: "index_block_time_statistics_on_stat_timestamp", unique: true + end + + create_table "blocks", force: :cascade do |t| + t.binary "block_hash" + t.decimal "number", precision: 30 + t.binary "parent_hash" + t.decimal "timestamp", precision: 30 + t.binary "transactions_root" + t.binary "proposals_hash" + t.integer "uncles_count" + t.binary "extra_hash" + t.binary "uncle_block_hashes" + t.integer "version" + t.binary "proposals" + t.integer "proposals_count" + t.decimal "cell_consumed", precision: 30 + t.binary "miner_hash" + t.decimal "reward", precision: 30 + t.decimal "total_transaction_fee", precision: 30 + t.decimal "ckb_transactions_count", precision: 30, default: "0" + t.decimal "total_cell_capacity", precision: 30 + t.decimal "epoch", precision: 30 + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false + t.string "address_ids", array: true + t.integer "reward_status", default: 0 + t.integer "received_tx_fee_status", default: 0 + t.decimal "received_tx_fee", precision: 30, default: "0" + t.integer "target_block_reward_status", default: 0 + t.binary "miner_lock_hash" + t.string "dao" + t.decimal "primary_reward", precision: 30, default: "0" + t.decimal "secondary_reward", precision: 30, default: "0" + t.decimal "nonce", precision: 50, default: "0" + t.decimal "start_number", precision: 30, default: "0" + t.decimal "length", precision: 30, default: "0" + t.decimal "compact_target", precision: 20 + t.integer "live_cell_changes" + t.decimal "block_time", precision: 13 + t.integer "block_size" + t.decimal "proposal_reward", precision: 30 + t.decimal "commit_reward", precision: 30 + t.string "miner_message" + t.jsonb "extension" + t.decimal "median_timestamp", default: "0.0" + t.index ["block_hash"], name: "index_blocks_on_block_hash", unique: true + t.index ["block_size"], name: "index_blocks_on_block_size" + t.index ["block_time"], name: "index_blocks_on_block_time" + t.index ["epoch"], name: "index_blocks_on_epoch" + t.index ["number"], name: "index_blocks_on_number" + t.index ["timestamp"], name: "index_blocks_on_timestamp", order: "DESC NULLS LAST" + end + + create_table "cell_inputs", force: :cascade do |t| + t.jsonb "previous_output" + t.bigint "ckb_transaction_id" + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false + t.bigint "previous_cell_output_id" + t.boolean "from_cell_base", default: false + t.decimal "block_id", precision: 30 + t.decimal "since", precision: 30, default: "0" + t.integer "cell_type", default: 0 + t.index ["block_id"], name: "index_cell_inputs_on_block_id" + t.index ["ckb_transaction_id"], name: "index_cell_inputs_on_ckb_transaction_id" + t.index ["previous_cell_output_id"], name: "index_cell_inputs_on_previous_cell_output_id" + end + + create_table "cell_outputs", force: :cascade do |t| + t.decimal "capacity", precision: 64, scale: 2 + t.binary "data" + t.bigint "ckb_transaction_id" + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false + t.integer "status", limit: 2, default: 0 + t.decimal "address_id", precision: 30 + t.decimal "block_id", precision: 30 + t.binary "tx_hash" + t.integer "cell_index" + t.decimal "generated_by_id", precision: 30 + t.decimal "consumed_by_id", precision: 30 + t.integer "cell_type", default: 0 + t.integer "data_size" + t.decimal "occupied_capacity", precision: 30 + t.decimal "block_timestamp", precision: 30 + t.decimal "consumed_block_timestamp", precision: 30, default: "0" + t.string "type_hash" + t.decimal "udt_amount", precision: 40 + t.string "dao" + t.bigint "lock_script_id" + t.bigint "type_script_id" + t.index ["address_id", "status"], name: "index_cell_outputs_on_address_id_and_status" + t.index ["block_id"], name: "index_cell_outputs_on_block_id" + t.index ["block_timestamp"], name: "index_cell_outputs_on_block_timestamp" + t.index ["ckb_transaction_id"], name: "index_cell_outputs_on_ckb_transaction_id" + t.index ["consumed_block_timestamp"], name: "index_cell_outputs_on_consumed_block_timestamp" + t.index ["consumed_by_id"], name: "index_cell_outputs_on_consumed_by_id" + t.index ["generated_by_id"], name: "index_cell_outputs_on_generated_by_id" + t.index ["lock_script_id"], name: "index_cell_outputs_on_lock_script_id" + t.index ["status"], name: "index_cell_outputs_on_status" + t.index ["tx_hash", "cell_index"], name: "index_cell_outputs_on_tx_hash_and_cell_index" + t.index ["type_script_id", "id"], name: "index_cell_outputs_on_type_script_id_and_id" + t.index ["type_script_id"], name: "index_cell_outputs_on_type_script_id" + end + + create_table "ckb_transactions", force: :cascade do |t| + t.binary "tx_hash" + t.bigint "block_id" + t.decimal "block_number", precision: 30 + t.decimal "block_timestamp", precision: 30 + t.decimal "transaction_fee", precision: 30 + t.integer "version" + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false + t.boolean "is_cellbase", default: false + t.binary "header_deps" + t.jsonb "cell_deps" + t.jsonb "witnesses" + t.integer "live_cell_changes" + t.decimal "capacity_involved", precision: 30 + t.bigint "contained_address_ids", default: [], array: true + t.string "tags", default: [], array: true + t.bigint "contained_udt_ids", default: [], array: true + t.bigint "dao_address_ids", default: [], array: true + t.bigint "udt_address_ids", default: [], array: true + t.index ["block_id", "block_timestamp"], name: "index_ckb_transactions_on_block_id_and_block_timestamp" + t.index ["block_timestamp", "id"], name: "index_ckb_transactions_on_block_timestamp_and_id", order: { block_timestamp: "DESC NULLS LAST", id: :desc } + t.index ["contained_address_ids", "id"], name: "index_ckb_transactions_on_contained_address_ids_and_id", using: :gin + t.index ["contained_udt_ids"], name: "index_ckb_transactions_on_contained_udt_ids", using: :gin + t.index ["dao_address_ids"], name: "index_ckb_transactions_on_dao_address_ids", using: :gin + t.index ["is_cellbase"], name: "index_ckb_transactions_on_is_cellbase" + t.index ["tags"], name: "index_ckb_transactions_on_tags", using: :gin + t.index ["tx_hash", "block_id"], name: "index_ckb_transactions_on_tx_hash_and_block_id", unique: true + t.index ["udt_address_ids"], name: "index_ckb_transactions_on_udt_address_ids", using: :gin + end + + create_table "daily_statistics", force: :cascade do |t| + t.string "transactions_count", default: "0" + t.string "addresses_count", default: "0" + t.string "total_dao_deposit", default: "0.0" + t.decimal "block_timestamp", precision: 30 + t.integer "created_at_unixtimestamp" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "dao_depositors_count", default: "0" + t.string "unclaimed_compensation", default: "0" + t.string "claimed_compensation", default: "0" + t.string "average_deposit_time", default: "0" + t.string "estimated_apc", default: "0" + t.string "mining_reward", default: "0" + t.string "deposit_compensation", default: "0" + t.string "treasury_amount", default: "0" + t.string "live_cells_count", default: "0" + t.string "dead_cells_count", default: "0" + t.string "avg_hash_rate", default: "0" + t.string "avg_difficulty", default: "0" + t.string "uncle_rate", default: "0" + t.string "total_depositors_count", default: "0" + t.decimal "total_tx_fee", precision: 30 + t.jsonb "address_balance_distribution" + t.decimal "occupied_capacity", precision: 30 + t.decimal "daily_dao_deposit", precision: 30 + t.integer "daily_dao_depositors_count" + t.decimal "daily_dao_withdraw", precision: 30 + t.decimal "circulation_ratio" + t.decimal "total_supply", precision: 30 + t.decimal "circulating_supply" + t.jsonb "block_time_distribution" + t.jsonb "epoch_time_distribution" + t.jsonb "epoch_length_distribution" + t.jsonb "average_block_time" + t.jsonb "nodes_distribution" + t.integer "nodes_count" + t.decimal "locked_capacity", precision: 30 + t.index ["created_at_unixtimestamp"], name: "index_daily_statistics_on_created_at_unixtimestamp", order: "DESC NULLS LAST" + end + + create_table "dao_contracts", force: :cascade do |t| + t.decimal "total_deposit", precision: 30, default: "0" + t.decimal "claimed_compensation", precision: 30, default: "0" + t.bigint "deposit_transactions_count", default: 0 + t.bigint "withdraw_transactions_count", default: 0 + t.integer "depositors_count", default: 0 + t.bigint "total_depositors_count", default: 0 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.decimal "unclaimed_compensation", precision: 30 + t.decimal "ckb_transactions_count", precision: 30, default: "0" + end + + create_table "dao_events", force: :cascade do |t| + t.bigint "block_id" + t.bigint "ckb_transaction_id" + t.bigint "address_id" + t.bigint "contract_id" + t.integer "event_type", limit: 2 + t.decimal "value", precision: 30, default: "0" + t.integer "status", limit: 2, default: 0 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.decimal "block_timestamp", precision: 30 + t.index ["block_id"], name: "index_dao_events_on_block_id" + t.index ["block_timestamp"], name: "index_dao_events_on_block_timestamp" + t.index ["status", "event_type"], name: "index_dao_events_on_status_and_event_type" + end + + create_table "epoch_statistics", force: :cascade do |t| + t.string "difficulty" + t.string "uncle_rate" + t.decimal "epoch_number", precision: 30 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "hash_rate" + t.decimal "epoch_time", precision: 13 + t.integer "epoch_length" + t.index ["epoch_number"], name: "index_epoch_statistics_on_epoch_number", unique: true + end + + create_table "forked_blocks", force: :cascade do |t| + t.binary "block_hash" + t.decimal "number", precision: 30 + t.binary "parent_hash" + t.decimal "timestamp", precision: 30 + t.binary "transactions_root" + t.binary "proposals_hash" + t.integer "uncles_count" + t.binary "extra_hash" + t.binary "uncle_block_hashes" + t.integer "version" + t.binary "proposals" + t.integer "proposals_count" + t.decimal "cell_consumed", precision: 30 + t.binary "miner_hash" + t.decimal "reward", precision: 30 + t.decimal "total_transaction_fee", precision: 30 + t.decimal "ckb_transactions_count", precision: 30, default: "0" + t.decimal "total_cell_capacity", precision: 30 + t.decimal "epoch", precision: 30 + t.string "address_ids", array: true + t.integer "reward_status", default: 0 + t.integer "received_tx_fee_status", default: 0 + t.decimal "received_tx_fee", precision: 30, default: "0" + t.integer "target_block_reward_status", default: 0 + t.binary "miner_lock_hash" + t.string "dao" + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false + t.decimal "primary_reward", precision: 30, default: "0" + t.decimal "secondary_reward", precision: 30, default: "0" + t.decimal "nonce", precision: 50, default: "0" + t.decimal "start_number", precision: 30, default: "0" + t.decimal "length", precision: 30, default: "0" + t.decimal "compact_target", precision: 20 + t.integer "live_cell_changes" + t.decimal "block_time", precision: 13 + t.integer "block_size" + t.decimal "proposal_reward", precision: 30 + t.decimal "commit_reward", precision: 30 + t.string "miner_message" + t.jsonb "extension" + t.decimal "median_timestamp", default: "0.0" + end + + create_table "forked_events", force: :cascade do |t| + t.decimal "block_number", precision: 30 + t.decimal "epoch_number", precision: 30 + t.decimal "block_timestamp", precision: 30 + t.integer "status", limit: 2, default: 0 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["status"], name: "index_forked_events_on_status" + end + + create_table "lock_scripts", force: :cascade do |t| + t.string "args" + t.binary "code_hash" + t.bigint "cell_output_id" + t.bigint "address_id" + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false + t.string "hash_type" + t.string "script_hash" + t.index ["address_id"], name: "index_lock_scripts_on_address_id" + t.index ["cell_output_id"], name: "index_lock_scripts_on_cell_output_id" + t.index ["code_hash", "hash_type", "args"], name: "index_lock_scripts_on_code_hash_and_hash_type_and_args" + t.index ["script_hash"], name: "index_lock_scripts_on_script_hash" + end + + create_table "mining_infos", force: :cascade do |t| + t.bigint "address_id" + t.bigint "block_id" + t.decimal "block_number", precision: 30 + t.integer "status", limit: 2, default: 0 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["block_id"], name: "index_mining_infos_on_block_id" + t.index ["block_number"], name: "index_mining_infos_on_block_number" + end + + create_table "nrc_factory_cells", force: :cascade do |t| + t.binary "code_hash" + t.string "hash_type" + t.string "args" + t.string "name" + t.string "symbol" + t.string "base_token_uri" + t.string "extra_data" + t.boolean "verified", default: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["code_hash", "hash_type", "args"], name: "index_nrc_factory_cells_on_code_hash_and_hash_type_and_args", unique: true + end + + create_table "pool_transaction_entries", force: :cascade do |t| + t.jsonb "cell_deps" + t.binary "tx_hash" + t.jsonb "header_deps" + t.jsonb "inputs" + t.jsonb "outputs" + t.jsonb "outputs_data" + t.integer "version" + t.jsonb "witnesses" + t.decimal "transaction_fee", precision: 30 + t.decimal "block_number", precision: 30 + t.decimal "block_timestamp", precision: 30 + t.decimal "cycles", precision: 30 + t.decimal "tx_size", precision: 30 + t.jsonb "display_inputs" + t.jsonb "display_outputs" + t.integer "tx_status", default: 0 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.text "detailed_message" + t.index ["tx_hash"], name: "index_pool_transaction_entries_on_tx_hash", unique: true + t.index ["tx_status"], name: "index_pool_transaction_entries_on_tx_status" + end + + create_table "table_record_counts", force: :cascade do |t| + t.string "table_name" + t.bigint "count" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["table_name", "count"], name: "index_table_record_counts_on_table_name_and_count" + end + + create_table "token_collections", force: :cascade do |t| + t.string "standard" + t.string "name" + t.text "description" + t.integer "creator_id" + t.string "icon_url" + t.integer "items_count" + t.integer "holders_count" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "symbol" + t.integer "cell_id" + t.boolean "verified", default: false + t.integer "type_script_id" + t.string "sn" + t.index ["cell_id"], name: "index_token_collections_on_cell_id" + t.index ["sn"], name: "index_token_collections_on_sn", unique: true + t.index ["type_script_id"], name: "index_token_collections_on_type_script_id" + end + + create_table "token_items", force: :cascade do |t| + t.integer "collection_id" + t.decimal "token_id", precision: 80 + t.string "name" + t.string "icon_url" + t.integer "owner_id" + t.string "metadata_url" + t.integer "cell_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "type_script_id" + t.index ["cell_id"], name: "index_token_items_on_cell_id" + t.index ["collection_id", "token_id"], name: "index_token_items_on_collection_id_and_token_id", unique: true + t.index ["owner_id"], name: "index_token_items_on_owner_id" + t.index ["type_script_id"], name: "index_token_items_on_type_script_id" + end + + create_table "token_transfers", force: :cascade do |t| + t.integer "item_id" + t.integer "from_id" + t.integer "to_id" + t.integer "transaction_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "action" + t.index ["from_id"], name: "index_token_transfers_on_from_id" + t.index ["item_id"], name: "index_token_transfers_on_item_id" + t.index ["to_id"], name: "index_token_transfers_on_to_id" + t.index ["transaction_id"], name: "index_token_transfers_on_transaction_id" + end + + create_table "transaction_propagation_delays", force: :cascade do |t| + t.string "tx_hash" + t.integer "created_at_unixtimestamp" + t.jsonb "durations" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["created_at_unixtimestamp"], name: "index_tx_propagation_timestamp" + end + + create_table "tx_display_infos", primary_key: "ckb_transaction_id", id: :bigint, default: nil, force: :cascade do |t| + t.jsonb "inputs" + t.jsonb "outputs" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.jsonb "income" + end + + create_table "type_scripts", force: :cascade do |t| + t.string "args" + t.binary "code_hash" + t.bigint "cell_output_id" + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false + t.string "hash_type" + t.string "script_hash" + t.index ["cell_output_id"], name: "index_type_scripts_on_cell_output_id" + t.index ["code_hash", "hash_type", "args"], name: "index_type_scripts_on_code_hash_and_hash_type_and_args" + t.index ["script_hash"], name: "index_type_scripts_on_script_hash" + end + + create_table "udt_accounts", force: :cascade do |t| + t.integer "udt_type" + t.string "full_name" + t.string "symbol" + t.integer "decimal" + t.decimal "amount", precision: 40, default: "0" + t.boolean "published", default: false + t.binary "code_hash" + t.string "type_hash" + t.bigint "address_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.bigint "udt_id" + t.string "nft_token_id" + t.index ["address_id"], name: "index_udt_accounts_on_address_id" + t.index ["type_hash", "address_id"], name: "index_udt_accounts_on_type_hash_and_address_id", unique: true + t.index ["udt_id"], name: "index_udt_accounts_on_udt_id" + end + + create_table "udts", force: :cascade do |t| + t.binary "code_hash" + t.string "hash_type" + t.string "args" + t.string "type_hash" + t.string "full_name" + t.string "symbol" + t.integer "decimal" + t.string "description" + t.string "icon_file" + t.string "operator_website" + t.decimal "addresses_count", precision: 30, default: "0" + t.decimal "total_amount", precision: 40, default: "0" + t.integer "udt_type" + t.boolean "published", default: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.decimal "block_timestamp", precision: 30 + t.binary "issuer_address" + t.decimal "ckb_transactions_count", precision: 30, default: "0" + t.bigint "nrc_factory_cell_id" + t.string "display_name" + t.string "uan" + t.index ["type_hash"], name: "index_udts_on_type_hash", unique: true + end + + create_table "uncle_blocks", force: :cascade do |t| + t.binary "block_hash" + t.decimal "number", precision: 30 + t.binary "parent_hash" + t.decimal "timestamp", precision: 30 + t.binary "transactions_root" + t.binary "proposals_hash" + t.binary "extra_hash" + t.integer "version" + t.binary "proposals" + t.integer "proposals_count" + t.bigint "block_id" + t.decimal "epoch", precision: 30 + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false + t.string "dao" + t.decimal "nonce", precision: 50, default: "0" + t.decimal "compact_target", precision: 20 + t.index ["block_hash", "block_id"], name: "index_uncle_blocks_on_block_hash_and_block_id", unique: true + t.index ["block_id"], name: "index_uncle_blocks_on_block_id" + end + +end diff --git a/db/migrate/20231017074221_remove_referring_cell_cell_output_id_index.rb b/db/migrate/20231017074221_remove_referring_cell_cell_output_id_index.rb deleted file mode 100644 index 84745cc36..000000000 --- a/db/migrate/20231017074221_remove_referring_cell_cell_output_id_index.rb +++ /dev/null @@ -1,5 +0,0 @@ -class RemoveReferringCellCellOutputIdIndex < ActiveRecord::Migration[7.0] - def change - remove_index :referring_cells, name: :index_referring_cells_on_cell_output_id, column: :cell_output_id - end -end diff --git a/lib/tasks/.keep b/lib/tasks/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/tasks/migration/init_contracts.rake b/lib/tasks/migration/init_contracts.rake new file mode 100644 index 000000000..47b26ca12 --- /dev/null +++ b/lib/tasks/migration/init_contracts.rake @@ -0,0 +1,54 @@ +namespace :migration do + desc "Usage: RAILS_ENV=production bundle exec rake migration:init_contracts" + task init_contracts: :environment do + ApplicationRecord.transaction do + if ENV['CKB_NET_MODE'] == 'mainnet' + hashes = [ + { code_hash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8', hash_type: 'type', name: 'SECP256K1/blake160', description: 'SECP256K1/blake160 is the default lock script to verify CKB transaction signature.', role: 'lock_script' }, + { code_hash: '0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8', hash_type: 'type', name: 'SECP256K1/multisig', description: 'SECP256K1/multisig is a script which allows a group of users to sign a single transaction.', role: 'lock_script' }, + { code_hash: '0xd369597ff47f29fbc0d47d2e3775370d1250b85140c670e4718af712983a2354', hash_type: 'type', name: 'Anyone-Can-Pay Lock', description: 'anyone_can_pay allows a recipient to provide cell capacity in asset transfer.', role: 'type_script' }, + { code_hash: '0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e', hash_type: 'type', name: 'Nervos DAO', description: 'Nervos DAO is a smart contract with which users can interact the same way as any smart contract on CKB.', role: 'type_script' }, + { code_hash: '0x5e7a36a77e68eecc013dfa2fe6a23f3b6c344b04005808694ae6dd45eea4cfd5', hash_type: 'type', name: 'Simple UDT', description: 'Simple UDT provides a way for dapp developers to issue custom tokens on Nervos CKB.', role: 'type_script' }, + { code_hash: '0xd01f5152c267b7f33b9795140c2467742e8424e49ebe2331caec197f7281b60a', hash_type: 'type', name: 'Unipass', description: 'Simple UDT provides a way for dapp developers to issue custom tokens on Nervos CKB.', role: 'type_script' }, + { code_hash: '0x1122a4fb54697cf2e6e3a96c9d80fd398a936559b90954c6e88eb7ba0cf652df', hash_type: 'type', name: 'CoTA', description: 'A Compact Token Aggregator Standard for Extremely Low Cost NFTs and FTs.', role: 'type_script' }, + { code_hash: '0x90ca618be6c15f5857d3cbd09f9f24ca6770af047ba9ee70989ec3b229419ac7', hash_type: 'type', name: 'CoTA Registry', description: 'A Compact Token Aggregator Standard for Extremely Low Cost NFTs and FTs.', role: 'type_script' }, + { code_hash: '0xbf43c3602455798c1a61a596e0d95278864c552fafe231c063b3fabf97a8febc', hash_type: 'type', name: 'PW Lock', description: "Forked from CKB's system scripts, and currently supports signature generated by personalSign and signTypedData from ethereum wallets.", role: 'type_script' }, + { code_hash: '0x000f87062a2fe9bb4a6cc475212ea11014b84deb32e0375ee51e6ec4a553e009', hash_type: 'type', name: 'godwoken_custodian_lock', description: 'Rollup uses the custodian lock to hold the deposited assets.', role: 'type_script' }, + { code_hash: '0xff602581f07667eef54232cce850cbca2c418b3418611c132fca849d1edcd775', hash_type: 'type', name: 'godwoken_deposit_lock', description: 'A layer1 user can join the Rollup by creating a deposit cell.', role: 'type_script' }, + { code_hash: '0x3714af858b8b82b2bb8f13d51f3cffede2dd8d352a6938334bb79e6b845e3658', hash_type: 'type', name: 'godwoken_withdrawal_lock', description: 'Withdrawal cells are generated in the RollupSubmitBlock action according to the block.withdrawals field.', role: 'type_script' }, + { code_hash: '0x628b5f956b46ae27b50819a9ebab79ce5f957e6899ba0c75b8e142de2ed0dcd2', hash_type: 'type', name: 'godwoken_challenge_lock', description: 'When a Godwoken node found that an invalid state exists in the Rollup, the node can send the RollupEnterChallenge action to the Rollup cell and generate a challenging cell.' }, + { code_hash: '0xb619184ab9142c51b0ee75f4e24bcec3d077eefe513115bad68836d06738fd2c', hash_type: 'type', name: 'godwoken_stake_lock', description: 'A block producer is required to provide a stake cell to perform the RollupSubmitBlock action.', role: 'type_script' }, + { code_hash: '0xa4398768d87bd17aea1361edc3accd6a0117774dc4ebc813bfa173e8ac0d086d', hash_type: 'type', name: 'omni_lock v1', description: 'Omnilock is a lock script designed for interoperability. It comes with built-in support for verification of transaction signing methods used in Bitcoin, Ethereum, EOS, and Dogecoin. Omnilock is also extensible, so more verification algorithms can be added in future.', role: 'lock_script' }, + { code_hash: '0x9b819793a64463aed77c615d6cb226eea5487ccfc0783043a587254cda2b6f26', hash_type: 'type', name: 'omni_lock v2', description: 'Omnilock is a lock script designed for interoperability. It comes with built-in support for verification of transaction signing methods used in Bitcoin, Ethereum, EOS, and Dogecoin. Omnilock is also extensible, so more verification algorithms can be added in future.', role: 'lock_script' }, + { code_hash: '0xfef1d086d9f74d143c60bf03bd04bab29200dbf484c801c72774f2056d4c6718', hash_type: 'type', name: 'godwoken_state_validator', description: 'State validator is the major script to verify the on-chain Rollup cell. Rollup cell is an identity cell on CKB, it stores the structure GlobalState which represents the layer-2 state.', role: 'type_script' }, + { code_hash: '0x096df264f38fff07f3acd318995abc2c71ae0e504036fe32bc38d5b6037364d4', hash_type: 'type', name: 'godwoken_eth_account_lock', description: 'A layer-2 lock script, ETH account lock is a script that verifies the layer-2 account signature.', role: 'type_script' } + ] + else + hashes = [ + { code_hash: '0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8', hash_type: 'type', name: 'SECP256K1/blake160', description: 'SECP256K1/blake160 is the default lock script to verify CKB transaction signature.', role:'lock_script' }, + { code_hash: '0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8', hash_type: 'type', name: 'SECP256K1/multisig', description: 'SECP256K1/multisig is a script which allows a group of users to sign a single transaction.', role:'lock_script' }, + { code_hash: '0x3419a1c09eb2567f6552ee7a8ecffd64155cffe0f1796e6e61ec088d740c1356', hash_type: 'type', name: 'Anyone-Can-Pay Lock', description: 'anyone_can_pay allows a recipient to provide cell capacity in asset transfer.', role: 'type_script' }, + { code_hash: '0x82d76d1b75fe2fd9a27dfbaa65a039221a380d76c926f378d3f81cf3e7e13f2e', hash_type: 'type', name: 'Nervos DAO', description: 'Nervos DAO is a smart contract with which users can interact the same way as any smart contract on CKB.', role: 'type_script' }, + { code_hash: '0xc5e5dcf215925f7ef4dfaf5f4b4f105bc321c02776d6e7d52a1db3fcd9d011a4', hash_type: 'type', name: 'Simple UDT', description: 'Simple UDT provides a way for dapp developers to issue custom tokens on Nervos CKB.' , role: 'type_script'}, + { code_hash: '0x3e1eb7ed4809b2d60650be96a40abfbdafb3fb942b7b37ec7709e64e2cd0a783', hash_type: 'type', name: 'Unipass', description: 'Simple UDT provides a way for dapp developers to issue custom tokens on Nervos CKB.', role: 'type_script' }, + { code_hash: '0x89cd8003a0eaf8e65e0c31525b7d1d5c1becefd2ea75bb4cff87810ae37764d8', hash_type: 'type', name: 'CoTA', description: 'A Compact Token Aggregator Standard for Extremely Low Cost NFTs and FTs.', role: 'type_script' }, + { code_hash: '0x9302db6cc1344b81a5efee06962abcb40427ecfcbe69d471b01b2658ed948075', hash_type: 'type', name: 'CoTA Registry', description: 'A Compact Token Aggregator Standard for Extremely Low Cost NFTs and FTs.', role: 'type_script', role: 'type_script' }, + { code_hash: '0x58c5f491aba6d61678b7cf7edf4910b1f5e00ec0cde2f42e0abb4fd9aff25a63', hash_type: 'type', name: 'PW Lock', description: "Forked from CKB's system scripts, and currently supports signature generated by personalSign and signTypedData from ethereum wallets.", role: 'type_script' }, + { code_hash: '0x85ae4db0dd83f428a31deb342e4000af37ce2c9645d9e619df00096e3c50a2bb', hash_type: 'type', name: 'godwoken_custodian_lock', description: 'Rollup uses the custodian lock to hold the deposited assets.', role: 'type_script' }, + { code_hash: '0x50704b84ecb4c4b12b43c7acb260ddd69171c21b4c0ba15f3c469b7d143f6f18', hash_type: 'type', name: 'godwoken_deposit_lock', description: 'A layer1 user can join the Rollup by creating a deposit cell.', role: 'type_script' }, + { code_hash: '0x06ae0706bb2d7997d66224741d3ec7c173dbb2854a6d2cf97088796b677269c6', hash_type: 'type', name: 'godwoken_withdrawal_lock', description: 'Withdrawal cells are generated in the RollupSubmitBlock action according to the block.withdrawals field.', role: 'type_script' }, + { code_hash: '0x5a86c3bf1e8648b6a6f8abe6875720ccf9745ab225b68fa7c195f9d6635dea80', hash_type: 'type', name: 'godwoken_challenge_lock', description: 'When a Godwoken node found that an invalid state exists in the Rollup, the node can send the RollupEnterChallenge action to the Rollup cell and generate a challenging cell.', role: 'type_script', role: 'type_script' }, + { code_hash: '0x7f5a09b8bd0e85bcf2ccad96411ccba2f289748a1c16900b0635c2ed9126f288', hash_type: 'type', name: 'godwoken_stake_lock', description: 'A block producer is required to provide a stake cell to perform the RollupSubmitBlock action.', role: 'type_script' }, + { code_hash: '0x79f90bb5e892d80dd213439eeab551120eb417678824f282b4ffb5f21bad2e1e', hash_type: 'type', name: 'omni_lock v1', description: 'Omnilock is a lock script designed for interoperability. It comes with built-in support for verification of transaction signing methods used in Bitcoin, Ethereum, EOS, and Dogecoin. Omnilock is also extensible, so more verification algorithms can be added in future.', role: 'lock_script' }, + { code_hash: '0xf329effd1c475a2978453c8600e1eaf0bc2087ee093c3ee64cc96ec6847752cb', hash_type: 'type', name: 'omni_lock v2', description: 'Omnilock is a lock script designed for interoperability. It comes with built-in support for verification of transaction signing methods used in Bitcoin, Ethereum, EOS, and Dogecoin. Omnilock is also extensible, so more verification algorithms can be added in future.', role: 'lock_script' }, + { code_hash: '0x1e44736436b406f8e48a30dfbddcf044feb0c9eebfe63b0f81cb5bb727d84854', hash_type: 'type', name: 'godwoken_state_validator', description: 'State validator is the major script to verify the on-chain Rollup cell. Rollup cell is an identity cell on CKB, it stores the structure GlobalState which represents the layer-2 state.', role: 'type_script' }, + { code_hash: '0x07521d0aa8e66ef441ebc31204d86bb23fc83e9edc58c19dbb1b0ebe64336ec0', hash_type: 'type', name: 'godwoken_eth_account_lock', description: 'A layer-2 lock script, ETH account lock is a script that verifies the layer-2 account signature.', role: 'type_script' } + ] + end + + hashes.each {|hash| Contract.create(hash) unless Contract.exists?(code_hash: hash[:code_hash]) } + end + + puts "done" + end +end