Skip to content

Commit

Permalink
chore: set statement_timeout for migration
Browse files Browse the repository at this point in the history
Signed-off-by: Miles Zhang <[email protected]>
  • Loading branch information
zmcNotafraid committed Dec 3, 2024
1 parent 54574b1 commit f886b3e
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 17 deletions.
9 changes: 3 additions & 6 deletions db/migrate/20240823071323_add_unique_index_to_lock_script.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
class AddUniqueIndexToLockScript < ActiveRecord::Migration[7.0]
def up
def change
# set 1 hour
execute "SET statement_timeout = 3600000"
execute "SET statement_timeout = 3600000;"

remove_index :lock_scripts, :script_hash
add_index :lock_scripts, :script_hash, unique: true
end

def down
execute "RESET statement_timeout"
execute "RESET statement_timeout;"
end
end
9 changes: 3 additions & 6 deletions db/migrate/20240823071420_add_unique_index_to_type_script.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
class AddUniqueIndexToTypeScript < ActiveRecord::Migration[7.0]
def up
def change
# set 1 hour
execute "SET statement_timeout = 3600000"
execute "SET statement_timeout = 3600000;"

remove_index :type_scripts, :script_hash
add_index :type_scripts, :script_hash, unique: true
end

def down
execute "RESET statement_timeout"
execute "RESET statement_timeout;"
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class ChangeCkbTransactionConfirmationTime < ActiveRecord::Migration[7.0]
def change
ActiveRecord::Base.connection.execute("SET statement_timeout = 0")
execute("SET statement_timeout = 0;")
change_column :ckb_transactions, :confirmation_time, :bigint
execute "RESET statement_timeout;"
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ def change
remove_index :cell_dependencies, column: %i[ckb_transaction_id contract_cell_id]

add_index :cell_dependencies, %i[ckb_transaction_id contract_cell_id dep_type], name: "index_cell_dependencies_on_tx_id_and_cell_id_and_dep_type", unique: true
execute "RESET statement_timeout;"
end
end
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
class AddSortedIndexToCellDependencies < ActiveRecord::Migration[7.0]
def change
ActiveRecord::Base.connection.execute("SET statement_timeout = 0")
execute("SET statement_timeout = 0;")

remove_index :cell_dependencies, column: :contract_cell_id
add_index :cell_dependencies, %i[contract_cell_id block_number tx_index],
order: { block_number: :desc, tx_index: :desc },
name: "index_on_cell_dependencies_contract_cell_block_tx"
execute "RESET statement_timeout;"
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class AddContractAnalyzedToCellDependency < ActiveRecord::Migration[7.0]
def change
ActiveRecord::Base.connection.execute("SET statement_timeout = 0")
add_column :cell_dependencies, :contract_analyzed, :boolean, default: false
end
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class AddContractAnalyzedIndexToCellDependency < ActiveRecord::Migration[7.0]
def change
execute("SET statement_timeout = 0;")
add_index :cell_dependencies, :contract_analyzed
execute "RESET statement_timeout;"
end
end
4 changes: 2 additions & 2 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6024,8 +6024,8 @@ INSERT INTO "schema_migrations" (version) VALUES
('20241114074433'),
('20241119014652'),
('20241121073245'),
('20241125100650');
('20241129000339');
('20241125100650'),
('20241129000339'),
('20241202072604');


0 comments on commit f886b3e

Please sign in to comment.