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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b95fafe9090ee138da10f43722f9a19e3ed1d49a6f6d005785752d65376cb99
4
- data.tar.gz: c8d90b141ced89ea6cf3634e047dba9c9d5927722be8f9fdb1b20c029b061131
3
+ metadata.gz: f47f7dac9883328a8746f8f3f699eaaa7fdde0e4b5a7145e60cc2e146fd56483
4
+ data.tar.gz: e2e005009371483e95c018661e2117f863a2d54726c452d39f79923712fbe351
5
5
  SHA512:
6
- metadata.gz: 7403ead024cd8a02a328ef60062876f2e1dab63ce82c9aa9a7b6527a8de33b7da0828d3861717c450392c3f5d36ae5c9cf848bb95a6476219e07b85becbe9e0a
7
- data.tar.gz: 525350d1c84656ad50da83970579a79a1d6bbc977a38893c880c5adc183611a19bba6a36160e285f2f2b5d1f3348a7657936db73abdd71619ba2592efd7d3f1c
6
+ metadata.gz: e72b79a725ebcf6e5f343602fc053fdfc0919f9b5fd91541584ee2f9b2eb638556fbddaf4e0e6a00d15f6c34d0bd2076d7cab6752294bb150b6df19138bca3d6
7
+ data.tar.gz: 3601009f81beb1e289baec9f4549b588b3168cd8f84ca7d2871bab5df3dd4e366e3759e6c70d64ded6c0c3a14d5947fa206e86321f2682eb88dc69a7a1981caf
@@ -1,6 +1,12 @@
1
1
  ##
2
2
  # Application controller 是模块内所有控制器的基类。
3
3
 
4
- class Unidom::Category::ApplicationController < ActionController::Base
5
- protect_from_forgery with: :exception
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,2 +1,8 @@
1
- module Unidom::Category::ApplicationHelper
1
+ module Unidom
2
+ module Category
3
+
4
+ module ApplicationHelper
5
+ end
6
+
7
+ end
2
8
  end
@@ -1,5 +1,11 @@
1
1
  ##
2
2
  # Application job 是模块内所有异步任务的基类。
3
3
 
4
- class Unidom::Category::ApplicationJob < ActiveJob::Base
4
+ module Unidom
5
+ module Category
6
+
7
+ class ApplicationJob < ActiveJob::Base
8
+ end
9
+
10
+ end
5
11
  end
@@ -1,7 +1,13 @@
1
1
  ##
2
2
  # Application mailer 是模块内所有电子邮件发送类的基类。
3
3
 
4
- class Unidom::Category::ApplicationMailer < ActionMailer::Base
5
- default from: 'from@example.com'
6
- layout 'mailer'
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
- class Unidom::Category::ApplicationRecord < ActiveRecord::Base
5
- self.abstract_class = true
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
- class Unidom::Category::Categorizing < Unidom::Category::ApplicationRecord
4
+ module Unidom
5
+ module Category
5
6
 
6
- self.table_name = 'unidom_categorizings'
7
+ class Categorizing < ApplicationRecord
7
8
 
8
- include Unidom::Common::Concerns::ModelExtension
9
+ self.table_name = 'unidom_categorizings'
9
10
 
10
- belongs_to :category, class_name: 'Unidom::Category::Category'
11
- belongs_to :categorized, polymorphic: true
11
+ include Unidom::Common::Concerns::ModelExtension
12
12
 
13
- scope :category_is, ->(category) { where category_id: to_id(category) }
14
- scope :categorized_is, ->(categorized) { where categorized: categorized }
13
+ belongs_to :category, class_name: 'Unidom::Category::Category'
14
+ belongs_to :categorized, polymorphic: true
15
15
 
16
- def self.categorize!(categorized, into: nil, at: Time.now)
16
+ scope :category_is, ->(category) { where category_id: to_id(category) }
17
+ scope :categorized_is, ->(categorized) { where categorized: categorized }
17
18
 
18
- assert_present! :categorized, categorized
19
- assert_present! :into, into
20
- assert_present! :at, at
19
+ def self.categorize!(categorized, into: nil, at: Time.now)
21
20
 
22
- categorized_is(categorized).category_is(into).valid_at.alive.first_or_create! elemental: true, opened_at: at
21
+ assert_present! :categorized, categorized
22
+ assert_present! :into, into
23
+ assert_present! :at, at
23
24
 
24
- end
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
- class Unidom::Category::Category < Unidom::Category::ApplicationRecord
4
+ module Unidom
5
+ module Category
5
6
 
6
- self.table_name = 'unidom_categories'
7
+ class Category < ApplicationRecord
7
8
 
8
- include Unidom::Common::Concerns::ModelExtension
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
- validates :name, presence: true, length: { in: 2..self.columns_hash['name'].limit }
14
- validates :abbreviation, allow_blank: true, length: { in: 2..self.columns_hash['abbreviation'].limit }
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
- belongs_to :scheme, class_name: 'Unidom::Category::CategoryScheme', foreign_key: :scheme_id
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
- scope :scheme_is, ->(scheme) { where scheme_id: to_id(scheme) }
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
- end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Category::Category'
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
- class Unidom::Category::CategoryRollup < Unidom::Category::ApplicationRecord
4
+ module Unidom
5
+ module Category
5
6
 
6
- self.table_name = 'unidom_category_rollups'
7
+ class CategoryRollup < ApplicationRecord
7
8
 
8
- include Unidom::Common::Concerns::ModelExtension
9
+ self.table_name = 'unidom_category_rollups'
9
10
 
10
- validates :distance, presence: true, numericality: { integer_only: true, greater_than: 0 }
11
+ include Unidom::Common::Concerns::ModelExtension
11
12
 
12
- belongs_to :ancestor_category, class_name: 'Unidom::Category::Category'
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
- scope :apart, ->(distance = 1) { where distance: distance }
15
+ belongs_to :ancestor_category, class_name: 'Unidom::Category::Category'
16
+ belongs_to :descendant_category, class_name: 'Unidom::Category::Category'
16
17
 
17
- scope :ancestor_category_is, ->(category) { where ancestor_category_id: to_id(category) }
18
- scope :descendant_category_is, ->(category) { where descendant_category_id: to_id(category) }
18
+ scope :apart, ->(distance = 1) { where distance: distance }
19
19
 
20
- after_create ->(record) {
21
- return unless 1==record.distance
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
- # it 归为 into 的下级分类,时间是 at ,缺省为当前时间。如:
34
- # Unidom::Category::CategoryRollup.roll_up! moto, into: vehicle
35
- def self.roll_up!(it, into: nil, at: Time.now)
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
- assert_present! :it, it
38
- assert_present! :into, into
39
- assert_present! :at, at
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
- self.descendant_category_is(it).ancestor_category_is(into).valid_at(now: at).alive.first_or_create! opened_at: at
40
+ assert_present! :it, it
41
+ assert_present! :into, into
42
+ assert_present! :at, at
42
43
 
43
- end
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
- class Unidom::Category::CategoryScheme < Unidom::Category::ApplicationRecord
5
+ module Unidom
6
+ module Category
6
7
 
7
- self.table_name = 'unidom_category_schemes'
8
+ class CategoryScheme < ApplicationRecord
8
9
 
9
- include Unidom::Common::Concerns::ModelExtension
10
+ self.table_name = 'unidom_category_schemes'
10
11
 
11
- belongs_to :owner, polymorphic: true
12
- has_many :categories, class_name: 'Unidom::Category::Category', foreign_key: :scheme_id
12
+ include Unidom::Common::Concerns::ModelExtension
13
13
 
14
- validates :name, presence: true, length: { in: 2..self.columns_hash['name'].limit }
14
+ belongs_to :owner, polymorphic: true
15
+ has_many :categories, class_name: 'Unidom::Category::Category', foreign_key: :scheme_id
15
16
 
16
- scope :owned_by, ->(owner) { where owner: owner }
17
+ validates :name, presence: true, length: { in: 2..self.columns_hash['name'].limit }
17
18
 
18
- end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Category::CategoryScheme'
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::Category::Concerns::AsAncestorCategory
1
+ module Unidom
2
+ module Category
3
+ module Concerns
4
+ module AsAncestorCategory
2
5
 
3
- extend ActiveSupport::Concern
6
+ extend ActiveSupport::Concern
4
7
 
5
- included do |includer|
8
+ included do |includer|
6
9
 
7
- has_many :descendant_category_rollups, class_name: 'Unidom::Category::CategoryRollup', foreign_key: :ancestor_category_id, source: :ancestor_category
8
- has_many :descendant_categories, class_name: 'Unidom::Category::Category', through: :descendant_category_rollups
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
- def roll_up!(it, at: Time.now, primary: true)
11
- rollup = descendant_category_rollups.descendant_category_is(it).valid_at(now: at).alive.first_or_create! elemental: primary, opened_at: at
12
- rollup.elemental = primary if rollup.elemental!=primary
13
- rollup.save!
14
- rollup
15
- end
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
- def roll_up?(it, at: Time.now, primary: true)
18
- descendant_category_rollups.descendant_category_is(it).primary(primary).valid_at(now: at).alive.exists?
19
- end
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
- end
24
+ end
22
25
 
23
- module ClassMethods
24
- end
26
+ module ClassMethods
27
+ end
25
28
 
29
+ end
30
+ end
31
+ end
26
32
  end
@@ -1,33 +1,39 @@
1
- module Unidom::Category::Concerns::AsCategorized
1
+ module Unidom
2
+ module Category
3
+ module Concerns
4
+ module AsCategorized
2
5
 
3
- extend ActiveSupport::Concern
6
+ extend ActiveSupport::Concern
4
7
 
5
- included do |includer|
8
+ included do |includer|
6
9
 
7
- has_many :categorizings, class_name: 'Unidom::Category::Categorizing', as: :categorized
8
- has_many :categories, through: :categorizings, source: :category
10
+ has_many :categorizings, class_name: 'Unidom::Category::Categorizing', as: :categorized
11
+ has_many :categories, through: :categorizings, source: :category
9
12
 
10
- def is_categorized!(into: nil, at: Time.now, primary: true)
13
+ def is_categorized!(into: nil, at: Time.now, primary: true)
11
14
 
12
- raise ArgumentError('The into argument is required.') if into.blank?
13
- raise ArgumentError('The at argument is required.' ) if at.blank?
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
- categorizings.category_is(into).valid_at(now: at).alive.first_or_create! elemental: primary, opened_at: at
18
+ categorizings.category_is(into).valid_at(now: at).alive.first_or_create! elemental: primary, opened_at: at
16
19
 
17
- end
20
+ end
18
21
 
19
- def is_categorized?(into: nil, at: Time.now, primary: true)
22
+ def is_categorized?(into: nil, at: Time.now, primary: true)
20
23
 
21
- raise ArgumentError('The into argument is required.') if into.blank?
22
- raise ArgumentError('The at argument is required.' ) if at.blank?
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
- categorizings.category_is(into).valid_at(now: at).alive.primary(primary).exists?
27
+ categorizings.category_is(into).valid_at(now: at).alive.primary(primary).exists?
25
28
 
26
- end
29
+ end
27
30
 
28
- end
31
+ end
29
32
 
30
- module ClassMethods
31
- end
33
+ module ClassMethods
34
+ end
32
35
 
36
+ end
37
+ end
38
+ end
33
39
  end
@@ -1,32 +1,38 @@
1
- module Unidom::Category::Concerns::AsCategory
1
+ module Unidom
2
+ module Category
3
+ module Concerns
4
+ module AsCategory
2
5
 
3
- extend ActiveSupport::Concern
6
+ extend ActiveSupport::Concern
4
7
 
5
- included do |includer|
8
+ included do |includer|
6
9
 
7
- has_many :categorizings, class_name: 'Category::Categorizing'
10
+ has_many :categorizings, class_name: 'Category::Categorizing'
8
11
 
9
- def categorize!(categorized, at: Time.now, primary: true)
12
+ def categorize!(categorized, at: Time.now, primary: true)
10
13
 
11
- raise ArgumentError('The categorized argument is required.') if categorized.blank?
12
- raise ArgumentError('The at argument is required.' ) if at.blank?
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
- categorizings.categorized_is(categorized).valid_at(now: at).alive.first_or_create! elemental: primary, opened_at: at
17
+ categorizings.categorized_is(categorized).valid_at(now: at).alive.first_or_create! elemental: primary, opened_at: at
15
18
 
16
- end
19
+ end
17
20
 
18
- def categorize?(categorized, at: Time.now, primary: true)
21
+ def categorize?(categorized, at: Time.now, primary: true)
19
22
 
20
- raise ArgumentError('The categorized argument is required.') if categorized.blank?
21
- raise ArgumentError('The at argument is required.' ) if at.blank?
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
- categorizings.categorized_is(categorized).valid_at(now: at).alive.primary(primary).exists?
26
+ categorizings.categorized_is(categorized).valid_at(now: at).alive.primary(primary).exists?
24
27
 
25
- end
28
+ end
26
29
 
27
- end
30
+ end
28
31
 
29
- module ClassMethods
30
- end
32
+ module ClassMethods
33
+ end
31
34
 
35
+ end
36
+ end
37
+ end
32
38
  end
@@ -1,26 +1,32 @@
1
- module Unidom::Category::Concerns::AsDescendantCategory
1
+ module Unidom
2
+ module Category
3
+ module Concerns
4
+ module AsDescendantCategory
2
5
 
3
- extend ActiveSupport::Concern
6
+ extend ActiveSupport::Concern
4
7
 
5
- included do |includer|
8
+ included do |includer|
6
9
 
7
- has_many :ancestor_category_rollups, class_name: 'Unidom::Category::CategoryRollup', foreign_key: :descendant_category_id, source: :descendant_category
8
- has_many :ancestor_categories, class_name: 'Unidom::Category::Category', through: :ancestor_category_rollups
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
- def is_rolled_up!(it, at: Time.now, primary: true)
11
- rollup = ancestor_category_rollups.ancestor_category_is(it).valid_at(now: at).alive.first_or_create! elemental: primary, opened_at: at
12
- rollup.elemental = primary if rollup.elemental!=primary
13
- rollup.save!
14
- rollup
15
- end
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
- def is_rolled_up?(it, at: Time.now, primary: true)
18
- ancestor_category_rollups.ancestor_category_is(it).primary(primary).valid_at(now: at).alive.exists?
19
- end
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
- end
24
+ end
22
25
 
23
- module ClassMethods
24
- end
26
+ module ClassMethods
27
+ end
25
28
 
29
+ end
30
+ end
31
+ end
26
32
  end
@@ -2,7 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>Unidom Category</title>
5
- <%= stylesheet_link_tag "unidom/category/application", media: 'all' %>
5
+ <%= stylesheet_link_tag 'unidom/category/application', media: 'all' %>
6
6
  <%= csrf_meta_tags %>
7
7
  </head>
8
8
  <body>
@@ -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: 'C'
16
- t.datetime :opened_at, null: false, default: ::Time.utc(1970)
17
- t.datetime :closed_at, null: false, default: ::Time.utc(3000)
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: 'C'
16
- t.datetime :opened_at, null: false, default: ::Time.utc(1970)
17
- t.datetime :closed_at, null: false, default: ::Time.utc(3000)
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
- t.references :descendant_category, type: :uuid, null: false
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: 'C'
14
- t.datetime :opened_at, null: false, default: ::Time.utc(1970)
15
- t.datetime :closed_at, null: false, default: ::Time.utc(3000)
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: 'C'
14
- t.datetime :opened_at, null: false, default: ::Time.utc(1970)
15
- t.datetime :closed_at, null: false, default: ::Time.utc(3000)
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
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Category
3
- VERSION = '2.0'.freeze
3
+ VERSION = '2.0.1'.freeze
4
4
  end
5
5
  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: '2.0'
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: 2020-04-20 00:00:00.000000000 Z
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://github.com/topbitdu/unidom-category
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.1.2
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: []