Skip to content

Commit

Permalink
attempt to move from mb3 to mb4...
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed May 12, 2024
1 parent 7a22150 commit 01d8217
Show file tree
Hide file tree
Showing 19 changed files with 91 additions and 61 deletions.
2 changes: 1 addition & 1 deletion app/models/annotation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Table name: annotations
#
# id :integer not null, primary key
# message :text(65535)
# message :text(16777215)
# source :string(255)
# created_at :datetime not null
# updated_at :datetime not null
Expand Down
2 changes: 1 addition & 1 deletion app/models/judgement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Table name: judgements
#
# id :bigint not null, primary key
# explanation :text(65535)
# explanation :text(16777215)
# judge_later :boolean default(FALSE)
# rating :float(24)
# unrateable :boolean default(FALSE)
Expand Down
4 changes: 2 additions & 2 deletions app/models/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# arranged_at :bigint
# arranged_next :bigint
# information_need :string(255)
# notes :text(65535)
# options :text(65535)
# notes :text(16777215)
# options :text(16777215)
# query_text :string(500)
# created_at :datetime not null
# updated_at :datetime not null
Expand Down
5 changes: 2 additions & 3 deletions app/models/query_doc_pair.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# id :bigint not null, primary key
# document_fields :text(16777215)
# information_need :string(255)
# notes :text(65535)
# options :text(65535)
# notes :text(16777215)
# options :text(16777215)
# position :integer
# query_text :string(500)
# created_at :datetime not null
Expand All @@ -19,7 +19,6 @@
# Indexes
#
# index_query_doc_pairs_on_book_id (book_id)
# unique_query_doc_pair (query_text,doc_id,book_id) UNIQUE
#
# Foreign Keys
#
Expand Down
2 changes: 1 addition & 1 deletion app/models/search_endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# basic_auth_credential :string(255)
# custom_headers :string(6000)
# endpoint_url :string(500)
# mapper_code :text(65535)
# mapper_code :text(16777215)
# name :string(255)
# options :json
# proxy_requests :boolean default(FALSE)
Expand Down
2 changes: 1 addition & 1 deletion app/models/try.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# field_spec :string(500)
# name :string(50)
# number_of_rows :integer default(10)
# query_params :string(20000)
# query_params :text(4294967295)
# try_number :integer
# created_at :datetime not null
# updated_at :datetime not null
Expand Down
34 changes: 34 additions & 0 deletions db/migrate/20240512131419_update_table_encoding.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class UpdateTableEncoding < ActiveRecord::Migration[7.1]
# As part of https://github.com/o19s/quepid/issues/1013
# finally going through and trying to update the database table charset and collations
#
@@tables_to_migrate = %w{annotations books case_metadata case_scores cases curator_variables judgements permissions queries query_doc_pairs ratings search_endpoints selection_strategies snapshot_docs snapshot_queries snapshots teams teams_cases teams_members teams_scorers tries users}
def up



puts "special handling of query_doc_pairs.document_fields column"
execute "ALTER TABLE query_doc_pairs MODIFY document_fields mediumtext CHARACTER SET utf8mb4;"

remove_index :query_doc_pairs, name: 'unique_query_doc_pair' if index_exists?(:query_doc_pairs, [:query_text, :doc_id, :book_id])
change_column :tries, :query_params, :text, limit: 16777215

@@tables_to_migrate.each do |table|
puts "Converting table #{table}"
execute "ALTER TABLE #{table} CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;"
end

#add_index :query_doc_pairs, [:query_text, :doc_id, :book_id], length: 255, unique: true, name: 'unique_query_doc_pair'

end

def down
puts "undo special handling of query_doc_pairs.document_fields column"
execute "ALTER TABLE query_doc_pairs MODIFY document_fields mediumtext CHARACTER SET utf8mb3;"

@@tables_to_migrate.each do |table|
puts "Undo Converting table #{table}"
execute "ALTER TABLE #{table} CONVERT TO CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci;"
end
end
end
69 changes: 34 additions & 35 deletions db/schema.rb

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

2 changes: 1 addition & 1 deletion test/fixtures/annotations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Table name: annotations
#
# id :integer not null, primary key
# message :text(65535)
# message :text(16777215)
# source :string(255)
# created_at :datetime not null
# updated_at :datetime not null
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/judgements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Table name: judgements
#
# id :bigint not null, primary key
# explanation :text(65535)
# explanation :text(16777215)
# judge_later :boolean default(FALSE)
# rating :float(24)
# unrateable :boolean default(FALSE)
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/queries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# arranged_at :bigint
# arranged_next :bigint
# information_need :string(255)
# notes :text(65535)
# options :text(65535)
# notes :text(16777215)
# options :text(16777215)
# query_text :string(500)
# created_at :datetime not null
# updated_at :datetime not null
Expand Down
5 changes: 2 additions & 3 deletions test/fixtures/query_doc_pairs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# id :bigint not null, primary key
# document_fields :text(16777215)
# information_need :string(255)
# notes :text(65535)
# options :text(65535)
# notes :text(16777215)
# options :text(16777215)
# position :integer
# query_text :string(500)
# created_at :datetime not null
Expand All @@ -17,7 +17,6 @@
# Indexes
#
# index_query_doc_pairs_on_book_id (book_id)
# unique_query_doc_pair (query_text,doc_id,book_id) UNIQUE
#
# Foreign Keys
#
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/search_endpoints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# basic_auth_credential :string(255)
# custom_headers :string(6000)
# endpoint_url :string(500)
# mapper_code :text(65535)
# mapper_code :text(16777215)
# name :string(255)
# options :json
# proxy_requests :boolean default(FALSE)
Expand Down

0 comments on commit 01d8217

Please sign in to comment.