From d24dbb6c098f9ee6be1980e90cd0c5b833d4f7b5 Mon Sep 17 00:00:00 2001 From: loiswells97 Date: Thu, 2 Mar 2023 14:52:26 +0000 Subject: [PATCH 1/2] Create draft PR for #140 From f5156a794fd7d9040cf524e190195567819aa8e8 Mon Sep 17 00:00:00 2001 From: Lois Wells Date: Thu, 2 Mar 2023 17:23:27 +0000 Subject: [PATCH 2/2] add and populate locale --- .../20230302145512_add_locale_to_projects.rb | 5 +++++ ...0302145905_mark_unowned_projects_as_english.rb | 15 +++++++++++++++ db/schema.rb | 3 ++- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20230302145512_add_locale_to_projects.rb create mode 100644 db/migrate/20230302145905_mark_unowned_projects_as_english.rb 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