diff --git a/app/models/memo.rb b/app/models/memo.rb index 37f98a339..2f927b646 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -43,4 +43,5 @@ class Memo < ApplicationRecord -end + belongs_to :author, :class_name => "User", foreign_key: :author_id, counter_cache: true + end diff --git a/app/models/resident_expert.rb b/app/models/resident_expert.rb new file mode 100644 index 000000000..ab792491d --- /dev/null +++ b/app/models/resident_expert.rb @@ -0,0 +1,2 @@ +class ResidentExpert < ApplicationRecord +end diff --git a/app/models/resident_expert_action.rb b/app/models/resident_expert_action.rb new file mode 100644 index 000000000..fb2ceebe2 --- /dev/null +++ b/app/models/resident_expert_action.rb @@ -0,0 +1,2 @@ +class ResidentExpertAction < ApplicationRecord +end diff --git a/app/models/user.rb b/app/models/user.rb index 2628a856e..fedd2fcb5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -195,6 +195,7 @@ class User < Owner has_many :user_vote_options, dependent: :destroy has_many :vote_options, through: :user_vote_options + has_many :memos, foreign_key: :author_id, dependent: :destroy # Groups and active users scope :active, lambda { where(status: [STATUS_ACTIVE, STATUS_EDIT_INFO]) } diff --git a/db/migrate/20260323060649_create_resident_experts.rb b/db/migrate/20260323060649_create_resident_experts.rb new file mode 100644 index 000000000..12a4c56c8 --- /dev/null +++ b/db/migrate/20260323060649_create_resident_experts.rb @@ -0,0 +1,20 @@ +class CreateResidentExperts < ActiveRecord::Migration[5.2] + def change + create_table :resident_experts do |t| + t.references :user + t.string :name + t.string :gender + t.integer :expert_category + t.integer :academic_degree + t.string :department + t.string :title + t.string :territory_area1 + t.string :territory_area2 + t.string :territory_area3 + t.text :introduction + t.integer :status, default: 0 + + t.timestamps + end + end +end diff --git a/db/migrate/20260323060719_create_resident_expert_actions.rb b/db/migrate/20260323060719_create_resident_expert_actions.rb new file mode 100644 index 000000000..2dfbe4739 --- /dev/null +++ b/db/migrate/20260323060719_create_resident_expert_actions.rb @@ -0,0 +1,12 @@ +class CreateResidentExpertActions < ActiveRecord::Migration[5.2] + def change + create_table :resident_expert_actions do |t| + t.references :resident_expert + t.integer :action_type, default: 0 + t.string :action_name + t.string :action_description + + t.timestamps + end + end +end diff --git a/db/migrate/20260323061746_add_memos_count_to_users.rb b/db/migrate/20260323061746_add_memos_count_to_users.rb new file mode 100644 index 000000000..c340dc58a --- /dev/null +++ b/db/migrate/20260323061746_add_memos_count_to_users.rb @@ -0,0 +1,11 @@ +class AddMemosCountToUsers < ActiveRecord::Migration[5.2] + def change + add_column :users, :memos_count, :integer, default: 0 + + User.find_each do |user| + User.reset_counters(user.id, :memos_count) + end + end + + +end