jobshop 0.0.167 → 0.0.179
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -2
- data/Rakefile +2 -1
- data/app/assets/javascripts/application.js +1 -0
- data/app/controllers/jobshop/application_controller.rb +3 -1
- data/app/controllers/jobshop/dashboards_controller.rb +11 -0
- data/app/controllers/jobshop/departments_controller.rb +52 -0
- data/app/controllers/jobshop/employees_controller.rb +77 -0
- data/app/controllers/jobshop/organizations_controller.rb +29 -0
- data/app/controllers/jobshop/rfqs_controller.rb +49 -0
- data/app/controllers/jobshop/roles_controller.rb +52 -0
- data/app/helpers/jobshop/application_helper.rb +10 -0
- data/app/listeners/jobshop/assignment_listener.rb +13 -0
- data/app/mailers/jobshop/rfq_responder_mailer.rb +1 -1
- data/app/models/jobshop/auditing.rb +20 -0
- data/app/models/jobshop/collection.rb +2 -7
- data/app/models/jobshop/customer.rb +6 -17
- data/app/models/jobshop/customer/category.rb +2 -8
- data/app/models/jobshop/customer/contact.rb +3 -8
- data/app/models/jobshop/department.rb +10 -0
- data/app/models/jobshop/department/assignment.rb +15 -0
- data/app/models/jobshop/employee.rb +13 -6
- data/app/models/jobshop/employment.rb +8 -8
- data/app/models/jobshop/inspection.rb +1 -1
- data/app/models/jobshop/inspection/boolean_criterion.rb +13 -17
- data/app/models/jobshop/inspection/criterion.rb +9 -10
- data/app/models/jobshop/inspection/deviation_criterion.rb +10 -12
- data/app/models/jobshop/inspection/limit_criterion.rb +12 -10
- data/app/models/jobshop/inspection/report.rb +22 -34
- data/app/models/jobshop/mailman.rb +2 -4
- data/app/models/jobshop/order.rb +3 -27
- data/app/models/jobshop/order_line.rb +4 -10
- data/app/models/jobshop/organization.rb +8 -15
- data/app/models/jobshop/organization_state.rb +10 -0
- data/app/models/jobshop/place.rb +3 -8
- data/app/models/jobshop/product.rb +4 -7
- data/app/models/jobshop/rfq.rb +32 -14
- data/app/models/jobshop/rfq/line.rb +28 -0
- data/app/models/jobshop/rfq/line/assignment.rb +25 -0
- data/app/models/jobshop/rfq/line/quantity.rb +23 -0
- data/app/models/jobshop/role.rb +3 -9
- data/app/models/jobshop/role_assignment.rb +10 -4
- data/app/models/jobshop/routing_process.rb +4 -10
- data/app/models/jobshop/routing_step.rb +3 -5
- data/app/models/jobshop/thing.rb +3 -8
- data/app/models/jobshop/user.rb +24 -11
- data/app/views/jobshop/dashboards/show.html.haml +35 -0
- data/app/views/jobshop/departments/_form.html.haml +12 -0
- data/app/views/jobshop/departments/edit.html.haml +7 -0
- data/app/views/jobshop/departments/index.html.haml +17 -0
- data/app/views/jobshop/departments/new.html.haml +5 -0
- data/app/views/jobshop/departments/show.html.haml +15 -0
- data/app/views/jobshop/employees/_form.html.haml +46 -0
- data/app/views/jobshop/employees/edit.html.haml +1 -0
- data/app/views/jobshop/employees/index.html.haml +12 -0
- data/app/views/jobshop/employees/new.html.haml +1 -0
- data/app/views/jobshop/employees/show.html.haml +16 -0
- data/app/views/jobshop/organizations/_form.html.haml +10 -0
- data/app/views/jobshop/organizations/edit.html.haml +7 -0
- data/app/views/jobshop/organizations/index.html.haml +19 -0
- data/app/views/jobshop/organizations/new.html.haml +5 -0
- data/app/views/jobshop/organizations/show.html.haml +16 -0
- data/app/views/jobshop/rfqs/_form.html.haml +60 -0
- data/app/views/jobshop/rfqs/edit.html.haml +4 -0
- data/app/views/jobshop/rfqs/index.html.haml +2 -0
- data/app/views/jobshop/roles/_form.html.haml +11 -0
- data/app/views/jobshop/roles/edit.html.haml +7 -0
- data/app/views/jobshop/roles/index.html.haml +21 -0
- data/app/views/jobshop/roles/new.html.haml +5 -0
- data/app/views/jobshop/roles/show.html.haml +3 -0
- data/app/views/layouts/jobshop/application.html.haml +50 -2
- data/config/initializers/devise.rb +2 -2
- data/config/routes.rb +18 -0
- data/db/migrate/20170311194758_initialize_jobshop.rb +4 -39
- data/db/migrate/20171216021339_create_organizations.rb +3 -8
- data/db/migrate/20171216021350_create_users.rb +28 -0
- data/db/migrate/20171216021400_create_employees.rb +27 -9
- data/db/migrate/20171216021853_create_customers.rb +29 -14
- data/db/migrate/20171216022020_create_places.rb +3 -4
- data/db/migrate/20171216022135_create_products.rb +4 -4
- data/db/migrate/20171216022605_create_orders.rb +27 -13
- data/db/migrate/20171216023018_create_roles.rb +30 -27
- data/db/migrate/20171216035357_create_things.rb +26 -23
- data/db/migrate/20171219022118_create_routing_processes.rb +28 -33
- data/db/migrate/20180107203241_create_inspections.rb +48 -115
- data/db/migrate/20181117023949_create_rfqs.rb +74 -15
- data/db/migrate/20181118014603_create_mailmen.rb +5 -6
- data/db/migrate/20190309163306_create_departments.rb +38 -0
- data/db/migrate/support/temporal_tables.sql +210 -0
- data/db/seeds.rb +92 -64
- data/exe/jobshop +1 -0
- data/lib/generators/jobshop/app/app_generator.rb +13 -3
- data/lib/generators/jobshop/app/templates/Procfile.tt +1 -1
- data/lib/generators/jobshop/app/templates/config/databases/postgresql.yml.tt +24 -0
- data/lib/generators/jobshop/app/templates/config/puma.rb.tt +44 -0
- data/lib/generators/jobshop/canary/canary_generator.rb +21 -9
- data/lib/generators/jobshop/dev_cert/dev_cert_generator.rb +124 -0
- data/lib/jobshop.rb +1 -1
- data/lib/jobshop/cli.rb +3 -3
- data/lib/jobshop/cli/app_generator.rb +15 -10
- data/lib/jobshop/cli/application.rb +7 -7
- data/lib/jobshop/cli/base.rb +65 -0
- data/lib/jobshop/cli/canary.rb +120 -22
- data/lib/jobshop/configuration.rb +1 -1
- data/lib/jobshop/engine.rb +8 -4
- data/lib/jobshop/helpers/migration.rb +27 -66
- data/lib/jobshop/mailroom/base_handler.rb +1 -1
- data/lib/jobshop/mailroom/null_handler.rb +1 -1
- data/lib/jobshop/mailroom/postmaster.rb +1 -1
- data/lib/jobshop/mailroom/rfq_handler.rb +1 -1
- data/lib/jobshop/version.rb +2 -2
- data/lib/tasks/jobshop_tasks.rake +15 -1
- metadata +114 -61
- data/app/controllers/jobshop/organizations/lookups_controller.rb +0 -18
- data/app/models/jobshop/employment_version.rb +0 -10
- data/app/models/jobshop/inspection/result.rb +0 -46
- data/app/models/jobshop/inspection/tuple.rb +0 -17
- data/app/models/jobshop/rfq_line.rb +0 -12
- data/db/migrate/20171216021554_create_people.rb +0 -43
- data/lib/generators/jobshop/app/templates/config/database.yml.tt +0 -19
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "jobshop/helpers/migration.rb"
|
4
|
+
|
5
|
+
class CreateUsers < ActiveRecord::Migration[5.2]
|
6
|
+
include Jobshop::Helpers::Migration
|
7
|
+
|
8
|
+
def change
|
9
|
+
create_table_with_auditing :jobshop_users do |t|
|
10
|
+
t.references :organization, type: :uuid, null: false,
|
11
|
+
foreign_key: { to_table: :jobshop_organizations }
|
12
|
+
|
13
|
+
t.index %i[ organization_id id ], unique: true
|
14
|
+
|
15
|
+
t.citext :email, null: false
|
16
|
+
|
17
|
+
t.index %i[ organization_id email ], unique: true
|
18
|
+
|
19
|
+
t.string :encrypted_password, null: false, default: ""
|
20
|
+
|
21
|
+
t.string :reset_password_token, index: { unique: true }
|
22
|
+
|
23
|
+
t.datetime :reset_password_sent_at
|
24
|
+
|
25
|
+
t.timestamps
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,37 +1,55 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "jobshop/helpers/migration.rb"
|
4
4
|
|
5
5
|
class CreateEmployees < ActiveRecord::Migration[5.2]
|
6
6
|
include Jobshop::Helpers::Migration
|
7
7
|
|
8
|
-
def change
|
8
|
+
def change
|
9
|
+
create_employees_table
|
10
|
+
create_employments_table
|
11
|
+
end
|
12
|
+
|
13
|
+
private def create_employees_table
|
9
14
|
create_table_with_auditing :jobshop_employees, primary_key: %i[
|
10
|
-
organization_id
|
15
|
+
organization_id id
|
11
16
|
] do |t|
|
17
|
+
t.references :user, type: :uuid, foreign_key: { to_table: :jobshop_users }
|
18
|
+
|
12
19
|
t.citext :email, null: false
|
20
|
+
|
13
21
|
t.string :forename
|
14
22
|
t.string :surname
|
23
|
+
|
15
24
|
t.timestamps
|
16
25
|
end
|
17
26
|
|
18
27
|
fk_organization :jobshop_employees
|
19
28
|
|
29
|
+
foreign_key :jobshop_employees, :jobshop_users,
|
30
|
+
{ organization_id: :organization_id, user_id: :id }
|
31
|
+
end
|
32
|
+
|
33
|
+
private def create_employments_table
|
20
34
|
create_table_with_auditing :jobshop_employments, primary_key: %i[
|
21
|
-
organization_id
|
35
|
+
organization_id id
|
22
36
|
] do |t|
|
23
|
-
t.uuid :
|
37
|
+
t.references :employee, type: :uuid, null: false,
|
38
|
+
foreign_key: { to_table: :jobshop_employees }
|
39
|
+
|
40
|
+
t.string :title, null: false, default: ""
|
41
|
+
|
24
42
|
t.date :started_on, default: { expr: "('now'::text)::date" }
|
25
43
|
t.date :ended_on
|
26
|
-
|
27
|
-
t.datetime :updated_at, null: false
|
28
|
-
t.uuid :updated_by_id
|
29
|
-
t.datetime :deleted_at
|
44
|
+
|
30
45
|
t.timestamps
|
31
46
|
end
|
32
47
|
|
33
48
|
fk_organization :jobshop_employments
|
34
49
|
|
50
|
+
foreign_key :jobshop_employments, :jobshop_employees,
|
51
|
+
{ organization_id: :organization_id, employee_id: :id }
|
52
|
+
|
35
53
|
execute <<~SQL
|
36
54
|
ALTER TABLE
|
37
55
|
jobshop_employments
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "jobshop/helpers/migration.rb"
|
4
4
|
|
@@ -6,30 +6,40 @@ class CreateCustomers < ActiveRecord::Migration[5.2]
|
|
6
6
|
include Jobshop::Helpers::Migration
|
7
7
|
|
8
8
|
def change
|
9
|
+
create_customer_categories_table
|
10
|
+
create_customers_table
|
11
|
+
create_customer_contacts_table
|
12
|
+
end
|
13
|
+
|
14
|
+
private def create_customer_categories_table
|
9
15
|
create_table_with_auditing :jobshop_customer_categories, primary_key: %i[
|
10
|
-
organization_id
|
16
|
+
organization_id id
|
11
17
|
] do |t|
|
12
18
|
t.citext :name, null: false
|
19
|
+
t.index %i[ organization_id name ], unique: true
|
20
|
+
|
13
21
|
t.text :description
|
14
22
|
end
|
15
23
|
|
16
|
-
add_index :jobshop_customer_categories, %i[ organization_id name ], unique: true
|
17
|
-
|
18
24
|
fk_organization :jobshop_customer_categories
|
25
|
+
end
|
19
26
|
|
27
|
+
private def create_customers_table
|
20
28
|
create_table_with_auditing :jobshop_customers, primary_key: %i[
|
21
|
-
organization_id
|
29
|
+
organization_id id
|
22
30
|
] do |t|
|
23
31
|
t.citext :name, null: false
|
24
|
-
t.
|
32
|
+
t.index %i[ organization_id name ], unique: true
|
33
|
+
|
34
|
+
t.references :category, type: :uuid, null: false, foreign_key:
|
35
|
+
{ to_table: :jobshop_customer_categories }
|
36
|
+
|
25
37
|
t.string :email_from_domain
|
38
|
+
|
26
39
|
t.timestamps
|
27
40
|
end
|
28
41
|
|
29
|
-
|
30
|
-
|
31
|
-
foreign_key :jobshop_customers, :jobshop_customer_categories,
|
32
|
-
%i[ organization_id category_id ]
|
42
|
+
fk_organization :jobshop_customers
|
33
43
|
|
34
44
|
# Reverse index on email_from_domain allows for search on just a domain
|
35
45
|
# given the entire address.
|
@@ -39,19 +49,24 @@ class CreateCustomers < ActiveRecord::Migration[5.2]
|
|
39
49
|
"organization_id, reverse(lower(email_from_domain)) text_pattern_ops",
|
40
50
|
name: :idx_jobshop_customers_reverse_address, unique: true
|
41
51
|
|
42
|
-
|
52
|
+
foreign_key :jobshop_customers, :jobshop_customer_categories,
|
53
|
+
{ organization_id: :organization_id, category_id: :id }
|
54
|
+
end
|
43
55
|
|
56
|
+
private def create_customer_contacts_table
|
44
57
|
create_table_with_auditing :jobshop_customer_contacts, primary_key: %i[
|
45
|
-
organization_id customer_id
|
58
|
+
organization_id customer_id id
|
46
59
|
] do |t|
|
47
60
|
t.citext :email, null: false
|
48
|
-
t.
|
61
|
+
t.index %i[ organization_id email ], unique: true
|
62
|
+
|
49
63
|
t.string :forename
|
64
|
+
t.string :surname
|
50
65
|
end
|
51
66
|
|
52
67
|
fk_organization :jobshop_customer_contacts
|
53
68
|
|
54
69
|
foreign_key :jobshop_customer_contacts, :jobshop_customers,
|
55
|
-
|
70
|
+
{ organization_id: :organization_id, customer_id: :id }
|
56
71
|
end
|
57
72
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "jobshop/helpers/migration.rb"
|
4
4
|
|
@@ -7,15 +7,14 @@ class CreatePlaces < ActiveRecord::Migration[5.2]
|
|
7
7
|
|
8
8
|
def change
|
9
9
|
create_table_with_auditing :jobshop_places, primary_key: %i[
|
10
|
-
organization_id
|
10
|
+
organization_id id
|
11
11
|
]do |t|
|
12
12
|
t.citext :name, null: false
|
13
|
+
t.index %i[ organization_id name ], unique: true
|
13
14
|
|
14
15
|
t.timestamps
|
15
16
|
end
|
16
17
|
|
17
|
-
add_index :jobshop_places, %i[ organization_id name ], unique: true
|
18
|
-
|
19
18
|
fk_organization :jobshop_places
|
20
19
|
end
|
21
20
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "jobshop/helpers/migration.rb"
|
4
4
|
|
@@ -7,16 +7,16 @@ class CreateProducts < ActiveRecord::Migration[5.2]
|
|
7
7
|
|
8
8
|
def change
|
9
9
|
create_table_with_auditing :jobshop_products, primary_key: %i[
|
10
|
-
organization_id
|
10
|
+
organization_id id
|
11
11
|
] do |t|
|
12
12
|
t.citext :name, null: false
|
13
|
+
t.index %i[ organization_id name ], unique: true
|
14
|
+
|
13
15
|
t.text :description
|
14
16
|
|
15
17
|
t.timestamps
|
16
18
|
end
|
17
19
|
|
18
|
-
add_index :jobshop_products, %i[ organization_id name ], unique: true
|
19
|
-
|
20
20
|
fk_organization :jobshop_products
|
21
21
|
end
|
22
22
|
end
|
@@ -1,38 +1,52 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "jobshop/helpers/migration.rb"
|
4
4
|
|
5
5
|
class CreateOrders < ActiveRecord::Migration[5.2]
|
6
6
|
include Jobshop::Helpers::Migration
|
7
7
|
|
8
|
-
def change
|
8
|
+
def change
|
9
|
+
create_orders_table
|
10
|
+
create_order_lines_table
|
11
|
+
end
|
12
|
+
|
13
|
+
private def create_orders_table
|
9
14
|
create_table_with_auditing :jobshop_orders, primary_key: %i[
|
10
|
-
organization_id
|
15
|
+
organization_id id
|
11
16
|
] do |t|
|
12
|
-
t.
|
17
|
+
t.references :customer, type: :uuid, null: false,
|
18
|
+
foreign_key: { to_table: :jobshop_customers }
|
19
|
+
|
13
20
|
t.string :number
|
21
|
+
t.index %i[ organization_id number ], unique: true
|
22
|
+
|
14
23
|
t.timestamps
|
15
24
|
end
|
16
25
|
|
17
|
-
add_index :jobshop_orders, %i[ organization_id number ], unique: true
|
18
|
-
add_index :jobshop_orders, %i[ organization_id customer_id ],
|
19
|
-
name: :idx_jobshop_orders_organization_customer
|
20
26
|
fk_organization :jobshop_orders
|
27
|
+
|
21
28
|
foreign_key :jobshop_orders, :jobshop_customers,
|
22
|
-
|
29
|
+
{ organization_id: :organization_id, customer_id: :id }
|
30
|
+
end
|
23
31
|
|
32
|
+
private def create_order_lines_table
|
24
33
|
create_table_with_auditing :jobshop_order_lines, primary_key: %i[
|
25
|
-
organization_id order_id
|
34
|
+
organization_id order_id id
|
26
35
|
] do |t|
|
27
|
-
t.
|
36
|
+
t.references :product, type: :uuid, null: false,
|
37
|
+
foreign_key: { to_table: :jobshop_products }
|
38
|
+
|
28
39
|
t.timestamps
|
29
40
|
end
|
30
41
|
|
31
|
-
add_index :jobshop_order_lines, %i[ organization_id product_id ]
|
32
42
|
fk_organization :jobshop_order_lines
|
43
|
+
|
44
|
+
add_index :jobshop_order_lines, %i[ organization_id product_id ]
|
45
|
+
|
33
46
|
foreign_key :jobshop_order_lines, :jobshop_orders,
|
34
|
-
|
47
|
+
{ organization_id: :organization_id, order_id: :id }
|
48
|
+
|
35
49
|
foreign_key :jobshop_order_lines, :jobshop_products,
|
36
|
-
|
50
|
+
{ organization_id: :organization_id, product_id: :id }
|
37
51
|
end
|
38
52
|
end
|
@@ -1,52 +1,55 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "jobshop/helpers/migration.rb"
|
4
4
|
|
5
5
|
class CreateRoles < ActiveRecord::Migration[5.2]
|
6
6
|
include Jobshop::Helpers::Migration
|
7
7
|
|
8
|
-
def change
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
name: :idx_jobshop_roles_pkey
|
8
|
+
def change
|
9
|
+
create_roles_table
|
10
|
+
create_role_assignments_table
|
11
|
+
# create_abilities_table
|
12
|
+
end
|
14
13
|
|
14
|
+
private def create_roles_table
|
15
|
+
create_table_with_auditing :jobshop_roles, primary_key: %i[
|
16
|
+
organization_id id
|
17
|
+
] do |t|
|
15
18
|
t.citext :name
|
19
|
+
|
20
|
+
t.references :resource, polymorphic: true
|
21
|
+
|
16
22
|
t.index %i[ organization_id name ], unique: true
|
23
|
+
t.index %i[ organization_id name resource_type resource_id ],
|
24
|
+
name: :idx_jobshop_roles_organization_name_type_id
|
17
25
|
|
18
26
|
t.timestamps
|
19
27
|
end
|
20
28
|
|
21
|
-
idx_table_name_pkey :jobshop_roles
|
22
29
|
fk_organization :jobshop_roles
|
30
|
+
end
|
23
31
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
t.
|
30
|
-
name: :jobshop_role_assignment_user_roles_ckey
|
31
|
-
t.index %i[ organization_id role_id person_id ], unique: true,
|
32
|
-
name: :jobshop_role_assignment_role_users_ckey
|
32
|
+
private def create_role_assignments_table
|
33
|
+
create_table_with_auditing :jobshop_role_assignments, primary_key: %i[
|
34
|
+
organization_id id
|
35
|
+
] do |t|
|
36
|
+
t.references :user, type: :uuid, foreign_key: { to_table: :jobshop_users }
|
37
|
+
t.references :role, type: :uuid, foreign_key: { to_table: :jobshop_roles }
|
33
38
|
|
34
|
-
t.
|
39
|
+
t.index %i[ organization_id user_id role_id ], unique: true,
|
40
|
+
name: :idx_jobshop_users_roles_organization_id_user_id_role_id
|
35
41
|
end
|
36
42
|
|
37
43
|
fk_organization :jobshop_role_assignments
|
44
|
+
end
|
38
45
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
%i[ organization_id person_id ]
|
44
|
-
|
45
|
-
create_table :jobshop_abilities, id: :uuid, default: "gen_random_uuid()" do |t|
|
46
|
-
t.uuid :organization_id, null: false
|
47
|
-
t.uuid :resource_id
|
46
|
+
private def create_abilities_table
|
47
|
+
create_table_with_auditing :jobshop_abilities, primary_key: %i[
|
48
|
+
organization_id id
|
49
|
+
] do |t|
|
48
50
|
t.string :resource_class, null: false
|
49
51
|
t.integer :action
|
52
|
+
t.uuid :resource_id
|
50
53
|
t.index %i[ organization_id resource_class action resource_id ],
|
51
54
|
unique: true, name: :idx_jobshop_abilities_secondary_key
|
52
55
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "jobshop/helpers/migration.rb"
|
4
4
|
|
@@ -6,41 +6,44 @@ class CreateThings < ActiveRecord::Migration[5.2]
|
|
6
6
|
include Jobshop::Helpers::Migration
|
7
7
|
|
8
8
|
def change
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
t.index %i[ organization_id thing_id ],
|
13
|
-
name: :idx_jobshop_things_pkey, unique: true
|
9
|
+
create_collections_table
|
10
|
+
create_things_table
|
11
|
+
end
|
14
12
|
|
15
|
-
|
13
|
+
private def create_collections_table
|
14
|
+
create_table_with_auditing :jobshop_collections, primary_key: %i[
|
15
|
+
organization_id id
|
16
|
+
] do |t|
|
16
17
|
t.citext :name
|
17
|
-
t.index %i[ organization_id
|
18
|
-
name: :idx_jobshop_organization_id_collection_id_name
|
18
|
+
t.index %i[ organization_id name ], unique: true
|
19
19
|
|
20
|
-
t.jsonb :
|
21
|
-
t.index :custom_fields, using: :gin
|
20
|
+
t.jsonb :schema, null: false, default: "{}"
|
22
21
|
|
23
22
|
t.timestamps
|
24
23
|
end
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
create_table :jobshop_collections, id: false do |t|
|
30
|
-
t.uuid :organization_id, null: false
|
31
|
-
t.uuid :collection_id, null: false, default: "gen_random_uuid()"
|
32
|
-
t.index %i[ organization_id collection_id ], unique: true,
|
33
|
-
name: :idx_jobshop_collections_pkey
|
25
|
+
fk_organization :jobshop_collections
|
26
|
+
end
|
34
27
|
|
28
|
+
private def create_things_table
|
29
|
+
create_table_with_auditing :jobshop_things, primary_key: %i[
|
30
|
+
organization_id id
|
31
|
+
]do |t|
|
32
|
+
t.references :collection, null: false, type: :uuid,
|
33
|
+
foreign_key: { to_table: :jobshop_collections }
|
35
34
|
t.citext :name
|
36
|
-
t.index %i[ organization_id name ], unique: true
|
35
|
+
t.index %i[ organization_id collection_id name ], unique: true,
|
36
|
+
name: :idx_jobshop_organization_id_collection_id_name
|
37
37
|
|
38
|
-
t.jsonb :
|
38
|
+
t.jsonb :custom_fields, null: false, default: "{}"
|
39
|
+
t.index :custom_fields, using: :gin
|
39
40
|
|
40
41
|
t.timestamps
|
41
42
|
end
|
42
43
|
|
43
|
-
|
44
|
-
|
44
|
+
fk_organization :jobshop_things
|
45
|
+
|
46
|
+
foreign_key :jobshop_things, :jobshop_collections,
|
47
|
+
{ organization_id: :organization_id, collection_id: :id }
|
45
48
|
end
|
46
49
|
end
|