unidom-category 2.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/unidom/category/application_controller.rb +8 -2
- data/app/helpers/unidom/category/application_helper.rb +7 -1
- data/app/jobs/unidom/category/application_job.rb +7 -1
- data/app/mailers/unidom/category/application_mailer.rb +9 -3
- data/app/models/unidom/category/application_record.rb +8 -2
- data/app/models/unidom/category/categorizing.rb +20 -14
- data/app/models/unidom/category/category.rb +19 -13
- data/app/models/unidom/category/category_rollup.rb +36 -30
- data/app/models/unidom/category/category_scheme.rb +14 -8
- data/app/models/unidom/category/concerns/as_ancestor_category.rb +23 -17
- data/app/models/unidom/category/concerns/as_categorized.rb +24 -18
- data/app/models/unidom/category/concerns/as_category.rb +23 -17
- data/app/models/unidom/category/concerns/as_descendant_category.rb +23 -17
- data/app/views/layouts/unidom/category/application.html.erb +1 -1
- data/db/migrate/20000301000000_create_unidom_category_schemes.rb +4 -4
- data/db/migrate/20000302000000_create_unidom_categories.rb +7 -6
- data/db/migrate/20000303000000_create_unidom_category_rollups.rb +10 -8
- data/db/migrate/20000304000000_create_unidom_categorizings.rb +7 -6
- data/lib/unidom/category/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f47f7dac9883328a8746f8f3f699eaaa7fdde0e4b5a7145e60cc2e146fd56483
|
4
|
+
data.tar.gz: e2e005009371483e95c018661e2117f863a2d54726c452d39f79923712fbe351
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e72b79a725ebcf6e5f343602fc053fdfc0919f9b5fd91541584ee2f9b2eb638556fbddaf4e0e6a00d15f6c34d0bd2076d7cab6752294bb150b6df19138bca3d6
|
7
|
+
data.tar.gz: 3601009f81beb1e289baec9f4549b588b3168cd8f84ca7d2871bab5df3dd4e366e3759e6c70d64ded6c0c3a14d5947fa206e86321f2682eb88dc69a7a1981caf
|
@@ -1,6 +1,12 @@
|
|
1
1
|
##
|
2
2
|
# Application controller 是模块内所有控制器的基类。
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
module Unidom
|
5
|
+
module Category
|
6
|
+
|
7
|
+
class ApplicationController < ActionController::Base
|
8
|
+
protect_from_forgery with: :exception
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
6
12
|
end
|
@@ -1,7 +1,13 @@
|
|
1
1
|
##
|
2
2
|
# Application mailer 是模块内所有电子邮件发送类的基类。
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
module Unidom
|
5
|
+
module Category
|
6
|
+
|
7
|
+
class ApplicationMailer < ActionMailer::Base
|
8
|
+
default from: 'from@example.com'
|
9
|
+
layout 'mailer'
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
7
13
|
end
|
@@ -1,6 +1,12 @@
|
|
1
1
|
##
|
2
2
|
# Application record 是模块内所有模型的抽象基类。
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
module Unidom
|
5
|
+
module Category
|
6
|
+
|
7
|
+
class ApplicationRecord < ActiveRecord::Base
|
8
|
+
self.abstract_class = true
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
6
12
|
end
|
@@ -1,26 +1,32 @@
|
|
1
1
|
##
|
2
2
|
# Categorizing 是分类(category)和被分类项(categorized)之间的关联关系。
|
3
3
|
|
4
|
-
|
4
|
+
module Unidom
|
5
|
+
module Category
|
5
6
|
|
6
|
-
|
7
|
+
class Categorizing < ApplicationRecord
|
7
8
|
|
8
|
-
|
9
|
+
self.table_name = 'unidom_categorizings'
|
9
10
|
|
10
|
-
|
11
|
-
belongs_to :categorized, polymorphic: true
|
11
|
+
include Unidom::Common::Concerns::ModelExtension
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
belongs_to :category, class_name: 'Unidom::Category::Category'
|
14
|
+
belongs_to :categorized, polymorphic: true
|
15
15
|
|
16
|
-
|
16
|
+
scope :category_is, ->(category) { where category_id: to_id(category) }
|
17
|
+
scope :categorized_is, ->(categorized) { where categorized: categorized }
|
17
18
|
|
18
|
-
|
19
|
-
assert_present! :into, into
|
20
|
-
assert_present! :at, at
|
19
|
+
def self.categorize!(categorized, into: nil, at: Time.now)
|
21
20
|
|
22
|
-
|
21
|
+
assert_present! :categorized, categorized
|
22
|
+
assert_present! :into, into
|
23
|
+
assert_present! :at, at
|
23
24
|
|
24
|
-
|
25
|
+
categorized_is(categorized).category_is(into).valid_at.alive.first_or_create! elemental: true, opened_at: at
|
26
|
+
|
27
|
+
end
|
25
28
|
|
26
|
-
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Category::Categorizing'
|
29
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Category::Categorizing'
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -1,22 +1,28 @@
|
|
1
1
|
##
|
2
2
|
# Category 是分类。
|
3
3
|
|
4
|
-
|
4
|
+
module Unidom
|
5
|
+
module Category
|
5
6
|
|
6
|
-
|
7
|
+
class Category < ApplicationRecord
|
7
8
|
|
8
|
-
|
9
|
-
include Unidom::Category::Concerns::AsCategory
|
10
|
-
include Unidom::Category::Concerns::AsAncestorCategory
|
11
|
-
include Unidom::Category::Concerns::AsDescendantCategory
|
9
|
+
self.table_name = 'unidom_categories'
|
12
10
|
|
13
|
-
|
14
|
-
|
11
|
+
include Unidom::Common::Concerns::ModelExtension
|
12
|
+
include Unidom::Category::Concerns::AsCategory
|
13
|
+
include Unidom::Category::Concerns::AsAncestorCategory
|
14
|
+
include Unidom::Category::Concerns::AsDescendantCategory
|
15
15
|
|
16
|
-
|
16
|
+
validates :name, presence: true, length: { in: 2..self.columns_hash['name'].limit }
|
17
|
+
validates :abbreviation, allow_blank: true, length: { in: 2..self.columns_hash['abbreviation'].limit }
|
17
18
|
|
18
|
-
|
19
|
-
scope :code_length_is, ->(length) { where 'LENGTH(code) = :code_length', code_length: length }
|
20
|
-
scope :code_starting_with, ->(prefix) { where 'code LIKE :prefix_expression', prefix_expression: prefix+'%' }
|
19
|
+
belongs_to :scheme, class_name: 'Unidom::Category::CategoryScheme', foreign_key: :scheme_id
|
21
20
|
|
22
|
-
|
21
|
+
scope :scheme_is, ->(scheme) { where scheme_id: to_id(scheme) }
|
22
|
+
scope :code_length_is, ->(length) { where 'LENGTH(code) = :code_length', code_length: length }
|
23
|
+
scope :code_starting_with, ->(prefix) { where 'code LIKE :prefix_expression', prefix_expression: prefix+'%' }
|
24
|
+
|
25
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Category::Category'
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -1,45 +1,51 @@
|
|
1
1
|
##
|
2
2
|
# Category Rollup 是分类的层级关系。
|
3
3
|
|
4
|
-
|
4
|
+
module Unidom
|
5
|
+
module Category
|
5
6
|
|
6
|
-
|
7
|
+
class CategoryRollup < ApplicationRecord
|
7
8
|
|
8
|
-
|
9
|
+
self.table_name = 'unidom_category_rollups'
|
9
10
|
|
10
|
-
|
11
|
+
include Unidom::Common::Concerns::ModelExtension
|
11
12
|
|
12
|
-
|
13
|
-
belongs_to :descendant_category, class_name: 'Unidom::Category::Category'
|
13
|
+
validates :distance, presence: true, numericality: { integer_only: true, greater_than: 0 }
|
14
14
|
|
15
|
-
|
15
|
+
belongs_to :ancestor_category, class_name: 'Unidom::Category::Category'
|
16
|
+
belongs_to :descendant_category, class_name: 'Unidom::Category::Category'
|
16
17
|
|
17
|
-
|
18
|
-
scope :descendant_category_is, ->(category) { where descendant_category_id: to_id(category) }
|
18
|
+
scope :apart, ->(distance = 1) { where distance: distance }
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
ancestor_category = record.ancestor_category_id
|
23
|
-
ancestor_category_rollups_1 = self.class.descendant_category_is(record.ancestor_category_id).alive
|
24
|
-
ancestor_category_rollups_1.each do |ancestor_category_rollup|
|
25
|
-
self.class.apart(1+ancestor_category_rollup.distance).
|
26
|
-
ancestor_category_is(ancestor_category_rollup.ancestor_category_id).
|
27
|
-
descendant_category_is(record.descendant_category_id).
|
28
|
-
first_or_create! elemental: ancestor_category_rollup.elemental, from_date: ancestor_category_rollup.from_date
|
29
|
-
end
|
30
|
-
}
|
20
|
+
scope :ancestor_category_is, ->(category) { where ancestor_category_id: to_id(category) }
|
21
|
+
scope :descendant_category_is, ->(category) { where descendant_category_id: to_id(category) }
|
31
22
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
23
|
+
after_create ->(record) {
|
24
|
+
return unless 1==record.distance
|
25
|
+
ancestor_category = record.ancestor_category_id
|
26
|
+
ancestor_category_rollups_1 = self.class.descendant_category_is(record.ancestor_category_id).alive
|
27
|
+
ancestor_category_rollups_1.each do |ancestor_category_rollup|
|
28
|
+
self.class.apart(1+ancestor_category_rollup.distance).
|
29
|
+
ancestor_category_is(ancestor_category_rollup.ancestor_category_id).
|
30
|
+
descendant_category_is(record.descendant_category_id).
|
31
|
+
first_or_create! elemental: ancestor_category_rollup.elemental, from_date: ancestor_category_rollup.from_date
|
32
|
+
end
|
33
|
+
}
|
36
34
|
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
##
|
36
|
+
# 将 it 归为 into 的下级分类,时间是 at ,缺省为当前时间。如:
|
37
|
+
# Unidom::Category::CategoryRollup.roll_up! moto, into: vehicle
|
38
|
+
def self.roll_up!(it, into: nil, at: Time.now)
|
40
39
|
|
41
|
-
|
40
|
+
assert_present! :it, it
|
41
|
+
assert_present! :into, into
|
42
|
+
assert_present! :at, at
|
42
43
|
|
43
|
-
|
44
|
+
self.descendant_category_is(it).ancestor_category_is(into).valid_at(now: at).alive.first_or_create! opened_at: at
|
45
|
+
|
46
|
+
end
|
44
47
|
|
45
|
-
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Category::CategoryRollup'
|
48
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Category::CategoryRollup'
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -2,17 +2,23 @@
|
|
2
2
|
# Category Scheme 是分类体系。
|
3
3
|
# 所有者(owner)可以是系统(System)、标准(Standard)、或者某个参与者(Party,如:Person、Shop、Company)。
|
4
4
|
|
5
|
-
|
5
|
+
module Unidom
|
6
|
+
module Category
|
6
7
|
|
7
|
-
|
8
|
+
class CategoryScheme < ApplicationRecord
|
8
9
|
|
9
|
-
|
10
|
+
self.table_name = 'unidom_category_schemes'
|
10
11
|
|
11
|
-
|
12
|
-
has_many :categories, class_name: 'Unidom::Category::Category', foreign_key: :scheme_id
|
12
|
+
include Unidom::Common::Concerns::ModelExtension
|
13
13
|
|
14
|
-
|
14
|
+
belongs_to :owner, polymorphic: true
|
15
|
+
has_many :categories, class_name: 'Unidom::Category::Category', foreign_key: :scheme_id
|
15
16
|
|
16
|
-
|
17
|
+
validates :name, presence: true, length: { in: 2..self.columns_hash['name'].limit }
|
17
18
|
|
18
|
-
|
19
|
+
scope :owned_by, ->(owner) { where owner: owner }
|
20
|
+
|
21
|
+
end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Category::CategoryScheme'
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -1,26 +1,32 @@
|
|
1
|
-
module Unidom
|
1
|
+
module Unidom
|
2
|
+
module Category
|
3
|
+
module Concerns
|
4
|
+
module AsAncestorCategory
|
2
5
|
|
3
|
-
|
6
|
+
extend ActiveSupport::Concern
|
4
7
|
|
5
|
-
|
8
|
+
included do |includer|
|
6
9
|
|
7
|
-
|
8
|
-
|
10
|
+
has_many :descendant_category_rollups, class_name: 'Unidom::Category::CategoryRollup', foreign_key: :ancestor_category_id, source: :ancestor_category
|
11
|
+
has_many :descendant_categories, class_name: 'Unidom::Category::Category', through: :descendant_category_rollups
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
def roll_up!(it, at: Time.now, primary: true)
|
14
|
+
rollup = descendant_category_rollups.descendant_category_is(it).valid_at(now: at).alive.first_or_create! elemental: primary, opened_at: at
|
15
|
+
rollup.elemental = primary if rollup.elemental!=primary
|
16
|
+
rollup.save!
|
17
|
+
rollup
|
18
|
+
end
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
+
def roll_up?(it, at: Time.now, primary: true)
|
21
|
+
descendant_category_rollups.descendant_category_is(it).primary(primary).valid_at(now: at).alive.exists?
|
22
|
+
end
|
20
23
|
|
21
|
-
|
24
|
+
end
|
22
25
|
|
23
|
-
|
24
|
-
|
26
|
+
module ClassMethods
|
27
|
+
end
|
25
28
|
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
26
32
|
end
|
@@ -1,33 +1,39 @@
|
|
1
|
-
module Unidom
|
1
|
+
module Unidom
|
2
|
+
module Category
|
3
|
+
module Concerns
|
4
|
+
module AsCategorized
|
2
5
|
|
3
|
-
|
6
|
+
extend ActiveSupport::Concern
|
4
7
|
|
5
|
-
|
8
|
+
included do |includer|
|
6
9
|
|
7
|
-
|
8
|
-
|
10
|
+
has_many :categorizings, class_name: 'Unidom::Category::Categorizing', as: :categorized
|
11
|
+
has_many :categories, through: :categorizings, source: :category
|
9
12
|
|
10
|
-
|
13
|
+
def is_categorized!(into: nil, at: Time.now, primary: true)
|
11
14
|
|
12
|
-
|
13
|
-
|
15
|
+
raise ArgumentError('The into argument is required.') if into.blank?
|
16
|
+
raise ArgumentError('The at argument is required.' ) if at.blank?
|
14
17
|
|
15
|
-
|
18
|
+
categorizings.category_is(into).valid_at(now: at).alive.first_or_create! elemental: primary, opened_at: at
|
16
19
|
|
17
|
-
|
20
|
+
end
|
18
21
|
|
19
|
-
|
22
|
+
def is_categorized?(into: nil, at: Time.now, primary: true)
|
20
23
|
|
21
|
-
|
22
|
-
|
24
|
+
raise ArgumentError('The into argument is required.') if into.blank?
|
25
|
+
raise ArgumentError('The at argument is required.' ) if at.blank?
|
23
26
|
|
24
|
-
|
27
|
+
categorizings.category_is(into).valid_at(now: at).alive.primary(primary).exists?
|
25
28
|
|
26
|
-
|
29
|
+
end
|
27
30
|
|
28
|
-
|
31
|
+
end
|
29
32
|
|
30
|
-
|
31
|
-
|
33
|
+
module ClassMethods
|
34
|
+
end
|
32
35
|
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
33
39
|
end
|
@@ -1,32 +1,38 @@
|
|
1
|
-
module Unidom
|
1
|
+
module Unidom
|
2
|
+
module Category
|
3
|
+
module Concerns
|
4
|
+
module AsCategory
|
2
5
|
|
3
|
-
|
6
|
+
extend ActiveSupport::Concern
|
4
7
|
|
5
|
-
|
8
|
+
included do |includer|
|
6
9
|
|
7
|
-
|
10
|
+
has_many :categorizings, class_name: 'Category::Categorizing'
|
8
11
|
|
9
|
-
|
12
|
+
def categorize!(categorized, at: Time.now, primary: true)
|
10
13
|
|
11
|
-
|
12
|
-
|
14
|
+
raise ArgumentError('The categorized argument is required.') if categorized.blank?
|
15
|
+
raise ArgumentError('The at argument is required.' ) if at.blank?
|
13
16
|
|
14
|
-
|
17
|
+
categorizings.categorized_is(categorized).valid_at(now: at).alive.first_or_create! elemental: primary, opened_at: at
|
15
18
|
|
16
|
-
|
19
|
+
end
|
17
20
|
|
18
|
-
|
21
|
+
def categorize?(categorized, at: Time.now, primary: true)
|
19
22
|
|
20
|
-
|
21
|
-
|
23
|
+
raise ArgumentError('The categorized argument is required.') if categorized.blank?
|
24
|
+
raise ArgumentError('The at argument is required.' ) if at.blank?
|
22
25
|
|
23
|
-
|
26
|
+
categorizings.categorized_is(categorized).valid_at(now: at).alive.primary(primary).exists?
|
24
27
|
|
25
|
-
|
28
|
+
end
|
26
29
|
|
27
|
-
|
30
|
+
end
|
28
31
|
|
29
|
-
|
30
|
-
|
32
|
+
module ClassMethods
|
33
|
+
end
|
31
34
|
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
32
38
|
end
|
@@ -1,26 +1,32 @@
|
|
1
|
-
module Unidom
|
1
|
+
module Unidom
|
2
|
+
module Category
|
3
|
+
module Concerns
|
4
|
+
module AsDescendantCategory
|
2
5
|
|
3
|
-
|
6
|
+
extend ActiveSupport::Concern
|
4
7
|
|
5
|
-
|
8
|
+
included do |includer|
|
6
9
|
|
7
|
-
|
8
|
-
|
10
|
+
has_many :ancestor_category_rollups, class_name: 'Unidom::Category::CategoryRollup', foreign_key: :descendant_category_id, source: :descendant_category
|
11
|
+
has_many :ancestor_categories, class_name: 'Unidom::Category::Category', through: :ancestor_category_rollups
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
def is_rolled_up!(it, at: Time.now, primary: true)
|
14
|
+
rollup = ancestor_category_rollups.ancestor_category_is(it).valid_at(now: at).alive.first_or_create! elemental: primary, opened_at: at
|
15
|
+
rollup.elemental = primary if rollup.elemental!=primary
|
16
|
+
rollup.save!
|
17
|
+
rollup
|
18
|
+
end
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
+
def is_rolled_up?(it, at: Time.now, primary: true)
|
21
|
+
ancestor_category_rollups.ancestor_category_is(it).primary(primary).valid_at(now: at).alive.exists?
|
22
|
+
end
|
20
23
|
|
21
|
-
|
24
|
+
end
|
22
25
|
|
23
|
-
|
24
|
-
|
26
|
+
module ClassMethods
|
27
|
+
end
|
25
28
|
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
26
32
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class CreateUnidomCategorySchemes < ActiveRecord::Migration
|
1
|
+
class CreateUnidomCategorySchemes < ActiveRecord::Migration[6.0]
|
2
2
|
|
3
3
|
def change
|
4
4
|
|
@@ -12,9 +12,9 @@ class CreateUnidomCategorySchemes < ActiveRecord::Migration
|
|
12
12
|
|
13
13
|
t.text :description
|
14
14
|
|
15
|
-
t.column :state, 'char(1)', null: false, default:
|
16
|
-
t.datetime :opened_at, null: false, default: ::
|
17
|
-
t.datetime :closed_at, null: false, default: ::
|
15
|
+
t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
|
16
|
+
t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
|
17
|
+
t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
|
18
18
|
t.boolean :defunct, null: false, default: false
|
19
19
|
t.jsonb :notation, null: false, default: {}
|
20
20
|
|
@@ -1,10 +1,11 @@
|
|
1
|
-
class CreateUnidomCategories < ActiveRecord::Migration
|
1
|
+
class CreateUnidomCategories < ActiveRecord::Migration[6.0]
|
2
2
|
|
3
3
|
def change
|
4
4
|
|
5
5
|
create_table :unidom_categories, id: :uuid do |t|
|
6
6
|
|
7
|
-
t.references :scheme, type: :uuid, null: false
|
7
|
+
t.references :scheme, type: :uuid, null: false,
|
8
|
+
foreign_key: false
|
8
9
|
|
9
10
|
t.string :code, null: true, default: nil, limit: 64
|
10
11
|
t.string :name, null: false, default: '', limit: 200
|
@@ -12,9 +13,9 @@ class CreateUnidomCategories < ActiveRecord::Migration
|
|
12
13
|
|
13
14
|
t.text :description
|
14
15
|
|
15
|
-
t.column :state, 'char(1)', null: false, default:
|
16
|
-
t.datetime :opened_at, null: false, default: ::
|
17
|
-
t.datetime :closed_at, null: false, default: ::
|
16
|
+
t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
|
17
|
+
t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
|
18
|
+
t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
|
18
19
|
t.boolean :defunct, null: false, default: false
|
19
20
|
t.jsonb :notation, null: false, default: {}
|
20
21
|
|
@@ -22,7 +23,7 @@ class CreateUnidomCategories < ActiveRecord::Migration
|
|
22
23
|
|
23
24
|
end
|
24
25
|
|
25
|
-
add_index :unidom_categories, :scheme_id
|
26
|
+
#add_index :unidom_categories, :scheme_id
|
26
27
|
add_index :unidom_categories, [ :code, :scheme_id ], unique: true
|
27
28
|
|
28
29
|
end
|
@@ -1,18 +1,20 @@
|
|
1
|
-
class CreateUnidomCategoryRollups < ActiveRecord::Migration
|
1
|
+
class CreateUnidomCategoryRollups < ActiveRecord::Migration[6.0]
|
2
2
|
|
3
3
|
def change
|
4
4
|
|
5
5
|
create_table :unidom_category_rollups, id: :uuid do |t|
|
6
6
|
|
7
|
-
t.references :ancestor_category, type: :uuid, null: false
|
8
|
-
|
7
|
+
t.references :ancestor_category, type: :uuid, null: false,
|
8
|
+
foreign_key: false
|
9
|
+
t.references :descendant_category, type: :uuid, null: false,
|
10
|
+
foreign_key: false
|
9
11
|
|
10
12
|
t.boolean :elemental, null: false, default: false
|
11
13
|
t.integer :distance, null: false, default: 1
|
12
14
|
|
13
|
-
t.column :state, 'char(1)', null: false, default:
|
14
|
-
t.datetime :opened_at, null: false, default: ::
|
15
|
-
t.datetime :closed_at, null: false, default: ::
|
15
|
+
t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
|
16
|
+
t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
|
17
|
+
t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
|
16
18
|
t.boolean :defunct, null: false, default: false
|
17
19
|
t.jsonb :notation, null: false, default: {}
|
18
20
|
|
@@ -20,8 +22,8 @@ class CreateUnidomCategoryRollups < ActiveRecord::Migration
|
|
20
22
|
|
21
23
|
end
|
22
24
|
|
23
|
-
add_index :unidom_category_rollups, :ancestor_category_id
|
24
|
-
add_index :unidom_category_rollups, :descendant_category_id
|
25
|
+
#add_index :unidom_category_rollups, :ancestor_category_id
|
26
|
+
#add_index :unidom_category_rollups, :descendant_category_id
|
25
27
|
|
26
28
|
end
|
27
29
|
|
@@ -1,18 +1,19 @@
|
|
1
|
-
class CreateUnidomCategorizings < ActiveRecord::Migration
|
1
|
+
class CreateUnidomCategorizings < ActiveRecord::Migration[6.0]
|
2
2
|
|
3
3
|
def change
|
4
4
|
|
5
5
|
create_table :unidom_categorizings, id: :uuid do |t|
|
6
6
|
|
7
|
-
t.references :category, type: :uuid, null: false
|
7
|
+
t.references :category, type: :uuid, null: false,
|
8
|
+
foreign_key: false
|
8
9
|
t.references :categorized, type: :uuid, null: false,
|
9
10
|
polymorphic: { type: :uuid, null: false }
|
10
11
|
|
11
12
|
t.boolean :elemental, null: false, default: false
|
12
13
|
|
13
|
-
t.column :state, 'char(1)', null: false, default:
|
14
|
-
t.datetime :opened_at, null: false, default: ::
|
15
|
-
t.datetime :closed_at, null: false, default: ::
|
14
|
+
t.column :state, 'char(1)', null: false, default: Unidom::Common::STATE
|
15
|
+
t.datetime :opened_at, null: false, default: Unidom::Common::OPENED_AT
|
16
|
+
t.datetime :closed_at, null: false, default: Unidom::Common::CLOSED_AT
|
16
17
|
t.boolean :defunct, null: false, default: false
|
17
18
|
t.jsonb :notation, null: false, default: {}
|
18
19
|
|
@@ -20,7 +21,7 @@ class CreateUnidomCategorizings < ActiveRecord::Migration
|
|
20
21
|
|
21
22
|
end
|
22
23
|
|
23
|
-
add_index :unidom_categorizings, :category_id
|
24
|
+
#add_index :unidom_categorizings, :category_id
|
24
25
|
add_index :unidom_categorizings, :categorized_id
|
25
26
|
|
26
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-category
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unidom-common
|
@@ -71,11 +71,11 @@ files:
|
|
71
71
|
- lib/unidom/category/types_rspec.rb
|
72
72
|
- lib/unidom/category/validators_rspec.rb
|
73
73
|
- lib/unidom/category/version.rb
|
74
|
-
homepage: https://
|
74
|
+
homepage: https://gitee.com/Unidom/unidom-category
|
75
75
|
licenses:
|
76
76
|
- MIT
|
77
77
|
metadata: {}
|
78
|
-
post_install_message:
|
78
|
+
post_install_message:
|
79
79
|
rdoc_options: []
|
80
80
|
require_paths:
|
81
81
|
- lib
|
@@ -90,8 +90,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
requirements: []
|
93
|
-
rubygems_version: 3.
|
94
|
-
signing_key:
|
93
|
+
rubygems_version: 3.2.3
|
94
|
+
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: Unidom Category Domain Model Engine 类别领域模型引擎
|
97
97
|
test_files: []
|