ecom_model 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +24 -0
- data/app/controllers/ecom_model/application_controller.rb +5 -0
- data/app/models/ecom/model/application_module.rb +7 -0
- data/app/models/ecom/model/application_record.rb +7 -0
- data/app/models/ecom/model/crew.rb +14 -0
- data/app/models/ecom/model/crew_time.rb +7 -0
- data/app/models/ecom/model/crew_type.rb +6 -0
- data/app/models/ecom/model/currency.rb +7 -0
- data/app/models/ecom/model/equipment_type.rb +6 -0
- data/app/models/ecom/model/material_type.rb +6 -0
- data/app/models/ecom/model/menu.rb +10 -0
- data/app/models/ecom/model/product_type.rb +10 -0
- data/app/models/ecom/model/project.rb +15 -0
- data/app/models/ecom/model/resource_type.rb +9 -0
- data/app/models/ecom/model/stakeholder.rb +11 -0
- data/app/models/ecom/model/stakeholder_type.rb +7 -0
- data/app/models/ecom/model/task.rb +10 -0
- data/app/models/ecom/model/task_template.rb +34 -0
- data/app/models/ecom/model/task_template_type.rb +7 -0
- data/app/models/ecom/model/user.rb +18 -0
- data/app/models/ecom/model/user_role.rb +12 -0
- data/app/models/ecom/model/work_component.rb +14 -0
- data/app/models/ecom/model/work_component_template.rb +11 -0
- data/app/models/ecom/model/work_product.rb +70 -0
- data/app/models/ecom/model/work_product_template.rb +14 -0
- data/config/database.ci.yml +12 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20191119010518_create_ecom_model_task_template_types.rb +13 -0
- data/db/migrate/20191119012030_create_ecom_model_task_templates.rb +15 -0
- data/db/migrate/20191119013236_create_ecom_model_work_product_templates.rb +15 -0
- data/db/migrate/20191119144141_create_ecom_model_stakeholder_types.rb +10 -0
- data/db/migrate/20191119144618_create_ecom_model_stakeholders.rb +19 -0
- data/db/migrate/20191119145711_create_ecom_model_resource_types.rb +15 -0
- data/db/migrate/20191201131341_create_ecom_model_product_types.rb +14 -0
- data/db/migrate/20191201134420_create_ecom_model_work_component_templates.rb +23 -0
- data/db/migrate/20191201145816_create_ecom_model_currencies.rb +10 -0
- data/db/migrate/20191201145848_create_ecom_model_projects.rb +34 -0
- data/db/migrate/20191202103735_create_ecom_model_tasks.rb +17 -0
- data/db/migrate/20191202105355_create_task_templates_resource_types.rb +16 -0
- data/db/migrate/20191202220752_create_ecom_model_application_modules.rb +10 -0
- data/db/migrate/20191202220832_create_ecom_model_users.rb +24 -0
- data/db/migrate/20191202220953_create_ecom_model_user_roles.rb +22 -0
- data/db/migrate/20191202221423_create_ecom_model_menus.rb +25 -0
- data/db/migrate/20191202235434_create_ecom_model_work_products.rb +35 -0
- data/db/migrate/20191206104247_create_ecom_model_work_components.rb +30 -0
- data/db/migrate/20191225100054_create_ecom_model_crews.rb +17 -0
- data/db/migrate/20191225211712_create_ecom_model_crew_times.rb +15 -0
- data/lib/ecom/model/engine.rb +19 -0
- data/lib/ecom/model/version.rb +5 -0
- data/lib/ecom/model.rb +4 -0
- data/lib/ecom_model.rb +4 -0
- data/lib/tasks/ecom_model_tasks.rake +4 -0
- data/spec/factories/ecom/model/application_modules.rb +6 -0
- data/spec/factories/ecom/model/crew_times.rb +9 -0
- data/spec/factories/ecom/model/crew_types.rb +5 -0
- data/spec/factories/ecom/model/crews.rb +12 -0
- data/spec/factories/ecom/model/currencies.rb +6 -0
- data/spec/factories/ecom/model/equipment_types.rb +5 -0
- data/spec/factories/ecom/model/material_types.rb +5 -0
- data/spec/factories/ecom/model/menus.rb +9 -0
- data/spec/factories/ecom/model/product_types.rb +7 -0
- data/spec/factories/ecom/model/projects.rb +23 -0
- data/spec/factories/ecom/model/resource_types.rb +8 -0
- data/spec/factories/ecom/model/stakeholder_types.rb +5 -0
- data/spec/factories/ecom/model/stakeholders.rb +13 -0
- data/spec/factories/ecom/model/task_template_types.rb +6 -0
- data/spec/factories/ecom/model/task_templates.rb +15 -0
- data/spec/factories/ecom/model/tasks.rb +10 -0
- data/spec/factories/ecom/model/user_roles.rb +6 -0
- data/spec/factories/ecom/model/users.rb +9 -0
- data/spec/factories/ecom/model/work_component_templates.rb +11 -0
- data/spec/factories/ecom/model/work_components.rb +18 -0
- data/spec/factories/ecom/model/work_product_templates.rb +9 -0
- data/spec/factories/ecom/model/work_products.rb +22 -0
- metadata +260 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ae057ad29a5b19baf253c593535cc843ef638e0eaf99053af18427c6144cefe1
|
4
|
+
data.tar.gz: 5f32b8c1759a16337b9f11570c4e90167b2556723538d45d5bab476a46775727
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 69c93e576f609c388c0fc9955f8f1e3a96d641af3deaccefc4efc69260eb2efbd4dc1b8d0b2c0df2479344fa5145106988a1c46ac34aecd50377de697ea1aa7e
|
7
|
+
data.tar.gz: 63e54faf17a5c0bf82f0d745eaf4d9b7dd6ec97119bca38df28d69ab9a65b1108f6fbc8cc6acaad0f12c482c97ff3929c7be793f8eeb3e8c1ce173f31132843b
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2019 Henock L.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# EcomModel
|
2
|
+
Short description and motivation.
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
How to use my plugin.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'ecom_model'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
```bash
|
21
|
+
$ gem install ecom_model
|
22
|
+
```
|
23
|
+
|
24
|
+
## Contributing
|
25
|
+
Contribution directions go here.
|
26
|
+
|
27
|
+
## License
|
28
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'EcomModel'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
load 'rails/tasks/statistics.rake'
|
21
|
+
|
22
|
+
require 'bundler/gem_tasks'
|
23
|
+
require 'rspec/core/rake_task'
|
24
|
+
RSpec::Core::RakeTask.new(spec: 'app:db:test:prepare')
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Model
|
3
|
+
class Crew < ApplicationRecord
|
4
|
+
PERMANENT = 'Permanent'.freeze
|
5
|
+
TEMPORARY = 'Temporary'.freeze
|
6
|
+
|
7
|
+
belongs_to :crew_type
|
8
|
+
|
9
|
+
validates :name, :qualification, presence: true
|
10
|
+
validates :wage, presence: true, if: ->(o) { o.employment == PERMANENT }
|
11
|
+
validates :wage, absence: true, if: ->(o) { o.employment == TEMPORARY }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Model
|
3
|
+
class Project < ApplicationRecord
|
4
|
+
belongs_to :employer, class_name: 'Ecom::Model::Stakeholder'
|
5
|
+
belongs_to :contractor, class_name: 'Ecom::Model::Stakeholder'
|
6
|
+
belongs_to :consultant, class_name: 'Ecom::Model::Stakeholder'
|
7
|
+
belongs_to :project_manager, class_name: 'Ecom::Model::Stakeholder'
|
8
|
+
belongs_to :task_template
|
9
|
+
belongs_to :currency
|
10
|
+
|
11
|
+
validates :name, :location, :contract_number, :date_contract_signed, :commencement_date, :completion_date,
|
12
|
+
:contract_amount, :advance_payment, :retention, presence: true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Model
|
3
|
+
class TaskTemplate < ApplicationRecord
|
4
|
+
has_ancestry
|
5
|
+
|
6
|
+
belongs_to :task_template_type
|
7
|
+
has_one :work_product_template
|
8
|
+
has_and_belongs_to_many :resource_types, join_table: 'ecom_model_task_templates_resource_types'
|
9
|
+
|
10
|
+
validates :name, :code, presence: true
|
11
|
+
validates :code, uniqueness: true
|
12
|
+
delegate(:name, to: :task_template_type, prefix: true)
|
13
|
+
|
14
|
+
def full_name
|
15
|
+
parent_name = parent&.name
|
16
|
+
return name unless parent_name
|
17
|
+
|
18
|
+
"#{name} - #{parent_name}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def crew_types
|
22
|
+
resource_types.where(type: 'Ecom::Model::CrewType')
|
23
|
+
end
|
24
|
+
|
25
|
+
def material_types
|
26
|
+
resource_types.where(type: 'Ecom::Model::MaterialType')
|
27
|
+
end
|
28
|
+
|
29
|
+
def equipment_types
|
30
|
+
resource_types.where(type: 'Ecom::Model::EquipmentType')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Model
|
3
|
+
class User < ApplicationRecord
|
4
|
+
has_secure_password
|
5
|
+
|
6
|
+
has_and_belongs_to_many :user_roles, join_table: 'ecom_model_users_user_roles'
|
7
|
+
|
8
|
+
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i.freeze
|
9
|
+
validates :first_name, :last_name, :active, presence: true
|
10
|
+
validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, uniqueness: { case_sensitive: false }
|
11
|
+
validates :password, length: { minimum: 6 }
|
12
|
+
|
13
|
+
def full_name
|
14
|
+
"#{first_name} #{last_name}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Model
|
3
|
+
class UserRole < ApplicationRecord
|
4
|
+
belongs_to :application_module
|
5
|
+
has_and_belongs_to_many :users, join_table: 'ecom_model_users_user_roles'
|
6
|
+
has_and_belongs_to_many :menus, join_table: 'ecom_model_menus_user_roles'
|
7
|
+
|
8
|
+
validates :name, presence: true
|
9
|
+
validates :name, uniqueness: { scope: :application_module_id }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Model
|
3
|
+
class WorkComponent < ApplicationRecord
|
4
|
+
belongs_to :performer, class_name: 'Ecom::Model::User'
|
5
|
+
belongs_to :approver, class_name: 'Ecom::Model::User'
|
6
|
+
belongs_to :supervisor, class_name: 'Ecom::Model::User'
|
7
|
+
belongs_to :quality_controller, class_name: 'Ecom::Model::User'
|
8
|
+
belongs_to :work_component_template
|
9
|
+
belongs_to :work_product
|
10
|
+
|
11
|
+
validates :name, :assignment_status, :task_status, :percent_completed, presence: true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Model
|
3
|
+
class WorkComponentTemplate < ApplicationRecord
|
4
|
+
belongs_to :work_product_template
|
5
|
+
belongs_to :task_template
|
6
|
+
|
7
|
+
validates :code, :name, presence: true
|
8
|
+
validates :code, uniqueness: { scope: %i[work_product_template_id task_template_id] }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# The WorkProduct model represents a task being implemented on a specific
|
2
|
+
# work product. To this regard, a work product is an assignable itself which
|
3
|
+
# contains the basic product attributes (e.g. dimension, name, design reference)
|
4
|
+
# on one hand, and task related attributes (e.g. start date and completion date)
|
5
|
+
# on the other hand. A task may have multiple work products under it. It is
|
6
|
+
# important to note that currently there is no direct way to link products and
|
7
|
+
# sub products, as we have done with tasks and sub tasks. If there is a desire
|
8
|
+
# to have such a link between products (e.g. we may later want to have reports
|
9
|
+
# per specific high level products, which in turn asks for finding all sub products
|
10
|
+
# under the selected high level product and do calculations), then a `code` field
|
11
|
+
# has been introduced to the WorkProduct model. This field can be used in a similar
|
12
|
+
# way as chart of accounts to identify parent and child relationships. Even then,
|
13
|
+
# there needs to be a well defined coding scheme developed before using the column
|
14
|
+
# field.
|
15
|
+
#
|
16
|
+
module Ecom
|
17
|
+
module Model
|
18
|
+
class WorkProduct < ApplicationRecord
|
19
|
+
include AASM
|
20
|
+
|
21
|
+
belongs_to :work_product_template
|
22
|
+
belongs_to :task
|
23
|
+
belongs_to :project
|
24
|
+
belongs_to :performer, class_name: 'Ecom::Model::User'
|
25
|
+
belongs_to :approver, class_name: 'Ecom::Model::User'
|
26
|
+
belongs_to :supervisor, class_name: 'Ecom::Model::User'
|
27
|
+
belongs_to :quality_controller, class_name: 'Ecom::Model::User'
|
28
|
+
|
29
|
+
validates :name, presence: true
|
30
|
+
validates :design_reference_no, uniqueness: true
|
31
|
+
|
32
|
+
aasm column: 'task_status' do
|
33
|
+
state :new, initial: true
|
34
|
+
state :in_progress
|
35
|
+
state :submitted
|
36
|
+
state :under_review
|
37
|
+
state :completed
|
38
|
+
|
39
|
+
event :start do
|
40
|
+
transitions from: :new, to: :in_progress
|
41
|
+
end
|
42
|
+
|
43
|
+
event :submit do
|
44
|
+
transitions from: :in_progress, to: :submitted
|
45
|
+
end
|
46
|
+
|
47
|
+
event :review do
|
48
|
+
transitions from: :submitted, to: :under_review
|
49
|
+
end
|
50
|
+
|
51
|
+
event :complete do
|
52
|
+
transitions from: %i[submitted under_review], to: :completed
|
53
|
+
end
|
54
|
+
|
55
|
+
event :rework do
|
56
|
+
transitions from: :under_review, to: :in_progress
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
aasm column: 'assignment_status' do
|
61
|
+
state :unassigned, initial: true
|
62
|
+
state :assigned
|
63
|
+
|
64
|
+
event :assign do
|
65
|
+
transitions from: :unassigned, to: :assigned
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ecom
|
2
|
+
module Model
|
3
|
+
class WorkProductTemplate < ApplicationRecord
|
4
|
+
validates :code, :name, presence: true, uniqueness: true
|
5
|
+
belongs_to :task_template
|
6
|
+
has_many :product_types
|
7
|
+
|
8
|
+
scope :filtered_by_template_type, lambda { |id|
|
9
|
+
joins(:task_template).where('ecom_model_task_templates.task_template_type_id = ?', id)
|
10
|
+
.order(:code)
|
11
|
+
}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
default: &default
|
2
|
+
adapter: postgresql
|
3
|
+
encoding: unicode
|
4
|
+
pool: 5
|
5
|
+
timeout: 5000
|
6
|
+
host: <%= ENV['DB_HOST'] %>
|
7
|
+
username: <%= ENV['POSTGRES_USER'] %>
|
8
|
+
password: <%= ENV['POSTGRES_PASSWORD'] %>
|
9
|
+
database: <%= ENV['POSTGRES_DB'] %>
|
10
|
+
|
11
|
+
test:
|
12
|
+
<<: *default
|
data/config/routes.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateEcomModelTaskTemplateTypes < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
create_table :ecom_model_task_template_types do |t|
|
4
|
+
t.string :code, null: false
|
5
|
+
t.string :name, null: false
|
6
|
+
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
|
10
|
+
add_index :ecom_model_task_template_types, :code, unique: true
|
11
|
+
add_index :ecom_model_task_template_types, :name, unique: true
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateEcomModelTaskTemplates < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
create_table :ecom_model_task_templates do |t|
|
4
|
+
t.string :code, null: false
|
5
|
+
t.string :name, null: false
|
6
|
+
t.string :description
|
7
|
+
t.references :task_template_type, index: { name: 'ttt_on_tt_indx' }
|
8
|
+
t.string :ancestry, index: true
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
|
13
|
+
add_foreign_key :ecom_model_task_templates, :ecom_model_task_template_types, column: :task_template_type_id
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateEcomModelWorkProductTemplates < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
create_table :ecom_model_work_product_templates do |t|
|
4
|
+
t.string :code, null: false, unique: true
|
5
|
+
t.string :name, null: false, unique: true
|
6
|
+
t.string :description
|
7
|
+
t.string :remark
|
8
|
+
t.references :task_template, index: { name: 'tt_on_wpt_indx' }
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
|
13
|
+
add_foreign_key :ecom_model_work_product_templates, :ecom_model_task_templates, column: :task_template_id
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CreateEcomModelStakeholders < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
create_table :ecom_model_stakeholders do |t|
|
4
|
+
t.string :name, null: false, unique: true
|
5
|
+
t.string :type_of_business
|
6
|
+
t.string :address
|
7
|
+
t.string :license_no
|
8
|
+
t.string :tin_no
|
9
|
+
t.string :contact_name, null: false
|
10
|
+
t.string :contact_phone, null: false
|
11
|
+
t.string :contact_email, null: false
|
12
|
+
t.references :stakeholder_type, index: { name: 'em_stakeholders_on_type_indx' }
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
|
17
|
+
add_foreign_key :ecom_model_stakeholders, :ecom_model_stakeholder_types, column: :stakeholder_type_id
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateEcomModelResourceTypes < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
create_table :ecom_model_resource_types do |t|
|
4
|
+
t.string :code, null: false
|
5
|
+
t.string :name, null: false
|
6
|
+
t.string :base_unit, null: false
|
7
|
+
t.string :type, null: false
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
|
12
|
+
add_index :ecom_model_resource_types, %i[code type], unique: true
|
13
|
+
add_index :ecom_model_resource_types, %i[name type], unique: true
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateEcomModelProductTypes < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
create_table :ecom_model_product_types do |t|
|
4
|
+
t.string :name, null: false
|
5
|
+
t.references :work_product_template, index: { name: 'pt_on_wpt_indx' }
|
6
|
+
t.json :dimension
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
|
11
|
+
add_index :ecom_model_product_types, %i[name work_product_template_id], unique: true, name: 'wpt_on_pt_name_indx'
|
12
|
+
add_foreign_key :ecom_model_product_types, :ecom_model_work_product_templates, column: :work_product_template_id
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class CreateEcomModelWorkComponentTemplates < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
create_table :ecom_model_work_component_templates do |t|
|
4
|
+
t.string :code, null: false
|
5
|
+
t.string :name, null: false
|
6
|
+
t.string :description
|
7
|
+
t.integer :relative_percentage
|
8
|
+
t.json :dimension
|
9
|
+
t.references :work_product_template, index: { name: 'wct_on_wpt_indx' }
|
10
|
+
t.references :task_template, index: { name: 'wct_on_tt_indx' }
|
11
|
+
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
|
15
|
+
add_index :ecom_model_work_component_templates, %i[code work_product_template_id task_template_id],
|
16
|
+
unique: true,
|
17
|
+
name: 'wct_on_code_wpt_id_tt_id_indx'
|
18
|
+
add_foreign_key :ecom_model_work_component_templates, :ecom_model_work_product_templates,
|
19
|
+
column: :work_product_template_id
|
20
|
+
add_foreign_key :ecom_model_work_component_templates, :ecom_model_task_templates,
|
21
|
+
column: :task_template_id
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class CreateEcomModelProjects < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
create_table :ecom_model_projects do |t|
|
4
|
+
t.string :name, null: false
|
5
|
+
t.string :description
|
6
|
+
t.string :location, null: false
|
7
|
+
t.string :objective
|
8
|
+
t.string :project_scope
|
9
|
+
t.references :employer, index: { name: 'employer_on_projects_indx' }
|
10
|
+
t.references :contractor, index: { name: 'employer_on_contractor_indx' }
|
11
|
+
t.references :consultant, index: { name: 'employer_on_consultant_indx' }
|
12
|
+
t.references :project_manager, index: { name: 'employer_on_pm_indx' }
|
13
|
+
t.references :task_template, index: { name: 'employer_on_tt_indx' }
|
14
|
+
t.string :contract_number, null: false
|
15
|
+
t.date :date_contract_signed, null: false
|
16
|
+
t.date :commencement_date, null: false
|
17
|
+
t.date :completion_date, null: false
|
18
|
+
t.float :contract_amount, null: false
|
19
|
+
t.float :advance_payment, null: false
|
20
|
+
t.float :retention, null: false
|
21
|
+
t.string :remark
|
22
|
+
t.references :currency, index: { name: 'employer_on_currency_indx' }
|
23
|
+
|
24
|
+
t.timestamps
|
25
|
+
end
|
26
|
+
|
27
|
+
add_foreign_key :ecom_model_projects, :ecom_model_stakeholders, column: :employer_id
|
28
|
+
add_foreign_key :ecom_model_projects, :ecom_model_stakeholders, column: :contractor_id
|
29
|
+
add_foreign_key :ecom_model_projects, :ecom_model_stakeholders, column: :consultant_id
|
30
|
+
add_foreign_key :ecom_model_projects, :ecom_model_stakeholders, column: :project_manager_id
|
31
|
+
add_foreign_key :ecom_model_projects, :ecom_model_task_templates, column: :task_template_id
|
32
|
+
add_foreign_key :ecom_model_projects, :ecom_model_currencies, column: :currency_id
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateEcomModelTasks < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
create_table :ecom_model_tasks do |t|
|
4
|
+
t.string :code, null: false
|
5
|
+
t.string :name, null: false
|
6
|
+
t.string :description
|
7
|
+
t.string :ancestry
|
8
|
+
t.references :project, index: { name: 'tasks_on_project_indx' }
|
9
|
+
t.references :task_template, index: { name: 'tt_on_project_indx' }
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
|
14
|
+
add_foreign_key :ecom_model_tasks, :ecom_model_projects, column: :project_id
|
15
|
+
add_foreign_key :ecom_model_tasks, :ecom_model_task_templates, column: :task_template_id
|
16
|
+
end
|
17
|
+
end
|