Add indexes.

This commit is contained in:
邱博亞 2024-07-14 22:57:37 +08:00
parent 061447c5d1
commit 99fa506a51
3 changed files with 15 additions and 5 deletions

View File

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

View File

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

View File

@ -7,7 +7,7 @@ class TableEntry
field :sort_number, type: Integer field :sort_number, type: Integer
has_many :column_entries, :dependent => :destroy 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 accepts_nested_attributes_for :column_entries, :allow_destroy => true