Add indexes.

This commit is contained in:
邱博亞 2024-07-14 22:48:52 +08:00
parent 061447c5d1
commit 6522e655b5
3 changed files with 14 additions and 4 deletions

View File

@ -11,8 +11,13 @@ class ColumnEntry
mount_uploader :image, ImageUploader
belongs_to :table_entry
belongs_to :table_column
belongs_to :table_entry, :dependent => :destroy, index: true
belongs_to :table_column, :dependent => :destroy, index: true
I18n.available_locales.each do |locale|
index({text: 1}, { collation: {locale: locale}, unique: false, background: true })
index({content: 1}, { collation: {locale: locale}, unique: false, background: true })
end
def type

View File

@ -14,7 +14,12 @@ class TableColumn
field :order_direction,type: String,default: 'desc'
belongs_to :u_table
has_many :column_entries, :dependent => :destroy
has_many :column_entries, :dependent => :destroy, index: true
index({display_in_index: -1}, { unique: false, background: true })
index({order: 1}, { unique: false, background: true })
index({key: 1}, { unique: false, background: true })
def sort_hash(direction)
case self.type
when "text"

View File

@ -7,7 +7,7 @@ class TableEntry
field :sort_number, type: Integer
has_many :column_entries, :dependent => :destroy
belongs_to :u_table
belongs_to :u_table, :dependent => :destroy, index: true
accepts_nested_attributes_for :column_entries, :allow_destroy => true