Skip to content

Commit

Permalink
fix migration and create rake task
Browse files Browse the repository at this point in the history
  • Loading branch information
Cesium-Ice committed Dec 26, 2024
1 parent 1717c51 commit f50904c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
11 changes: 0 additions & 11 deletions db/migrate/20241224082840_create_locale_languages.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
class CreateLocaleLanguages < ActiveRecord::Migration[7.0]
def change
ActiveRecord::Base.connection.execute("CREATE TABLE locale_languages LIKE languages;")

ActiveRecord::Base.connection.execute("INSERT INTO locale_languages SELECT * FROM languages;")

# Only if you care about the name of the index being consistent
# remove_index :locale_languages, column: [:short], name: "index_languages_on_short"
# remove_index :locale_languages, column: [:sortable_name], name: "index_languages_on_sortable_name"

# change_table :locale_languages do |t|
# t.index :short
# t.index :sortable_name
# end
end
end
14 changes: 14 additions & 0 deletions lib/tasks/after_tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -358,5 +358,19 @@ namespace :After do
puts("Admin not found.")
end
end

desc "Populate locale_languages table from languages table"
task(populate_locale_languages_table: :environment) do
Language.find_each do |lang|
LocaleLanguage.new do |ll|
ll.name = lang.name
ll.short = lang.short
ll.support_available = lang.support_available
ll.abuse_support_available = lang.abuse_support_available
ll.sortable_name = lang.sortable_name
ll.save
end
end
end
# This is the end that you have to put new tasks above.
end

0 comments on commit f50904c

Please sign in to comment.