diff --git a/db/migrate/20230302145512_add_locale_to_projects.rb b/db/migrate/20230302145512_add_locale_to_projects.rb new file mode 100644 index 000000000..45e8485d2 --- /dev/null +++ b/db/migrate/20230302145512_add_locale_to_projects.rb @@ -0,0 +1,5 @@ +class AddLocaleToProjects < ActiveRecord::Migration[7.0] + def change + add_column :projects, :project_locale, :string + end +end diff --git a/db/migrate/20230302145905_mark_unowned_projects_as_english.rb b/db/migrate/20230302145905_mark_unowned_projects_as_english.rb new file mode 100644 index 000000000..787cbdd77 --- /dev/null +++ b/db/migrate/20230302145905_mark_unowned_projects_as_english.rb @@ -0,0 +1,15 @@ +class MarkUnownedProjectsAsEnglish < ActiveRecord::Migration[7.0] + def up + Project.find_each do |project| + if project.user_id.nil? + project.update_attribute(:project_locale, 'en') + end + end + end + + def down + Project.find_each do |project| + project.update_attribute(:project_locale, nil) + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 19abe38d3..4a20dd90b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_02_10_142728) do +ActiveRecord::Schema[7.0].define(version: 2023_03_02_145905) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" enable_extension "plpgsql" @@ -121,6 +121,7 @@ t.datetime "created_at", null: false t.datetime "updated_at", null: false t.uuid "remixed_from_id" + t.string "project_locale" t.index ["identifier"], name: "index_projects_on_identifier", unique: true t.index ["remixed_from_id"], name: "index_projects_on_remixed_from_id" end