jobshop 0.0.157 → 0.0.163

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -1
  3. data/app/email_handlers/jobshop/rfq_handler.rb +43 -0
  4. data/app/models/jobshop/collection.rb +6 -11
  5. data/app/models/jobshop/company.rb +25 -12
  6. data/app/models/jobshop/company/type.rb +17 -0
  7. data/app/models/jobshop/company_person.rb +15 -0
  8. data/app/models/jobshop/inspection.rb +2 -0
  9. data/app/models/jobshop/inspection/boolean_criterion.rb +13 -10
  10. data/app/models/jobshop/inspection/criterion.rb +8 -11
  11. data/app/models/jobshop/inspection/deviation_criterion.rb +13 -10
  12. data/app/models/jobshop/inspection/limit_criterion.rb +9 -7
  13. data/app/models/jobshop/inspection/report.rb +11 -15
  14. data/app/models/jobshop/inspection/result.rb +9 -5
  15. data/app/models/jobshop/inspection/tuple.rb +7 -3
  16. data/app/models/jobshop/mailman.rb +11 -0
  17. data/app/models/jobshop/order.rb +12 -14
  18. data/app/models/jobshop/order_line.rb +10 -5
  19. data/app/models/jobshop/organization.rb +35 -8
  20. data/app/models/jobshop/person.rb +30 -0
  21. data/app/models/jobshop/place.rb +3 -1
  22. data/app/models/jobshop/product.rb +10 -12
  23. data/app/models/jobshop/rfq.rb +22 -0
  24. data/app/models/jobshop/rfq_line.rb +12 -0
  25. data/app/models/jobshop/role.rb +6 -13
  26. data/app/models/jobshop/role_assignment.rb +4 -2
  27. data/app/models/jobshop/routing_process.rb +8 -11
  28. data/app/models/jobshop/routing_step.rb +4 -2
  29. data/app/models/jobshop/thing.rb +6 -11
  30. data/app/models/jobshop/user.rb +10 -17
  31. data/db/migrate/20170311194758_initialize_jobshop.rb +3 -1
  32. data/db/migrate/20171216021339_create_organizations.rb +4 -2
  33. data/db/migrate/20171216021554_create_people.rb +48 -0
  34. data/db/migrate/20171216021853_create_companies.rb +47 -8
  35. data/db/migrate/20171216022020_create_places.rb +3 -3
  36. data/db/migrate/20171216022135_create_products.rb +5 -3
  37. data/db/migrate/20171216022605_create_orders.rb +9 -7
  38. data/db/migrate/20171216023018_create_roles.rb +18 -16
  39. data/db/migrate/20171216023022_create_sessions.rb +9 -7
  40. data/db/migrate/20171216035357_create_things.rb +7 -5
  41. data/db/migrate/20171219022118_create_routing_processes.rb +10 -8
  42. data/db/migrate/{20180107203241_create_inspection.rb → 20180107203241_create_inspections.rb} +21 -16
  43. data/db/migrate/20181117023949_create_rfqs.rb +40 -0
  44. data/db/migrate/20181118014603_create_mailmen.rb +29 -0
  45. data/exe/jobshop +1 -1
  46. data/lib/generators/jobshop/app/app_generator.rb +12 -23
  47. data/lib/generators/jobshop/app/templates/Procfile.tt +1 -0
  48. data/lib/generators/jobshop/config/templates/config/initializers/jobshop.rb.tt +5 -0
  49. data/lib/generators/jobshop/dummy/dummy_generator.rb +4 -5
  50. data/lib/jobshop.rb +8 -4
  51. data/lib/jobshop/cli.rb +58 -47
  52. data/lib/jobshop/configuration.rb +17 -5
  53. data/lib/jobshop/dummy_app.rb +27 -15
  54. data/lib/jobshop/engine.rb +28 -15
  55. data/lib/jobshop/helpers/migration.rb +6 -2
  56. data/lib/jobshop/postmaster.rb +89 -0
  57. data/lib/jobshop/version.rb +2 -2
  58. data/lib/tasks/jobshop_tasks.rake +11 -0
  59. metadata +83 -16
  60. data/db/migrate/20171216021717_create_users.rb +0 -30
@@ -1,17 +1,17 @@
1
1
  require "jobshop/helpers/migration.rb"
2
2
 
3
- class CreatePlaces < ActiveRecord::Migration[5.1]
3
+ class CreatePlaces < ActiveRecord::Migration[5.2]
4
4
  include Jobshop::Helpers::Migration
5
5
 
6
6
  def change
7
7
  create_table :jobshop_places, id: false do |t|
8
8
  t.uuid :organization_id, null: false
9
9
  t.uuid :place_id, null: false, default: "gen_random_uuid()"
10
- t.index [ :organization_id, :place_id ], unique: true,
10
+ t.index %i[ organization_id place_id ], unique: true,
11
11
  name: "idx_jobshop_places_pkey"
12
12
 
13
13
  t.citext :name, null: false
14
- t.index [ :organization_id, :name ], unique: true
14
+ t.index %i[ organization_id name ], unique: true
15
15
 
16
16
  t.timestamps
17
17
  end
@@ -1,19 +1,21 @@
1
+ # frozen_string_literals: true
2
+
1
3
  require "jobshop/helpers/migration.rb"
2
4
 
3
- class CreateProducts < ActiveRecord::Migration[5.1]
5
+ class CreateProducts < ActiveRecord::Migration[5.2]
4
6
  include Jobshop::Helpers::Migration
5
7
 
6
8
  def change
7
9
  create_table :jobshop_products, id: false do |t|
8
10
  t.uuid :organization_id, null: false
9
11
  t.uuid :product_id, null: false, default: "gen_random_uuid()"
10
- t.index [ :organization_id, :product_id ], unique: true,
12
+ t.index %i[ organization_id product_id ], unique: true,
11
13
  name: "idx_jobshop_products_pkey"
12
14
 
13
15
  t.uuid :created_by_id, null: false
14
16
 
15
17
  t.citext :name, null: false
16
- t.index [ :organization_id, :name ], unique: true
18
+ t.index %i[ organization_id name ], unique: true
17
19
 
18
20
  t.text :description
19
21
 
@@ -1,22 +1,24 @@
1
+ # frozen_string_literals: true
2
+
1
3
  require "jobshop/helpers/migration.rb"
2
4
 
3
- class CreateOrders < ActiveRecord::Migration[5.1]
5
+ class CreateOrders < ActiveRecord::Migration[5.2]
4
6
  include Jobshop::Helpers::Migration
5
7
 
6
- def change
8
+ def change # rubocop:disable Metrics/MethodLength
7
9
  create_table :jobshop_orders, id: false do |t|
8
10
  t.uuid :organization_id, null: false
9
11
  t.uuid :order_id, null: false, default: "gen_random_uuid()"
10
- t.index [ :organization_id, :order_id ], unique: true,
12
+ t.index %i[ organization_id order_id ], unique: true,
11
13
  name: "idx_jobshop_orders_pkey"
12
14
 
13
15
  t.uuid :created_by_id, null: false
14
16
 
15
17
  t.uuid :company_id, null: false
16
- t.index [ :organization_id, :company_id ]
18
+ t.index %i[ organization_id company_id ]
17
19
 
18
20
  t.string :number
19
- t.index [ :organization_id, :number ], unique: true
21
+ t.index %i[ organization_id number ], unique: true
20
22
 
21
23
  t.timestamps
22
24
  end
@@ -31,13 +33,13 @@ class CreateOrders < ActiveRecord::Migration[5.1]
31
33
  t.uuid :organization_id, null: false
32
34
  t.uuid :order_id, null: false
33
35
  t.uuid :order_line_id, null: false, default: "gen_random_uuid()"
34
- t.index [ :organization_id, :order_id, :order_line_id ], unique: true,
36
+ t.index %i[ organization_id order_id order_line_id ], unique: true,
35
37
  name: "idx_jobshop_order_lines_pkey"
36
38
 
37
39
  t.uuid :created_by_id, null: false
38
40
 
39
41
  t.uuid :product_id, null: false
40
- t.index [ :organization_id, :product_id ]
42
+ t.index %i[ organization_id product_id ]
41
43
 
42
44
  t.timestamps
43
45
  end
@@ -1,52 +1,54 @@
1
+ # frozen_string_literals: true
2
+
1
3
  require "jobshop/helpers/migration.rb"
2
4
 
3
- class CreateRoles < ActiveRecord::Migration[5.1]
5
+ class CreateRoles < ActiveRecord::Migration[5.2]
4
6
  include Jobshop::Helpers::Migration
5
7
 
6
- def change
8
+ def change # rubocop:disable Metrics/MethodLength
7
9
  create_table :jobshop_roles, id: false do |t|
8
10
  t.uuid :organization_id, null: false
9
11
  t.uuid :role_id, null: false, default: "gen_random_uuid()"
10
- t.index [ :organization_id, :role_id ], unique: true,
12
+ t.index %i[ organization_id role_id ], unique: true,
11
13
  name: :idx_jobshop_roles_pkey
12
14
 
13
15
  t.citext :name
14
- t.index [ :organization_id, :name ], unique: true
16
+ t.index %i[ organization_id name ], unique: true
15
17
 
16
18
  t.timestamps
17
19
  end
18
20
 
19
- idx_table_name_pkey "jobshop_roles"
20
- fk_organization_id "jobshop_roles"
21
+ idx_table_name_pkey :jobshop_roles
22
+ fk_organization_id :jobshop_roles
21
23
 
22
24
  create_table :jobshop_role_assignments, id: false do |t|
23
25
  t.uuid :organization_id, null: false
24
- t.uuid :user_id, null: false
26
+ t.uuid :person_id, null: false
25
27
  t.uuid :role_id, null: false
26
28
 
27
- t.index [ :organization_id, :user_id, :role_id ], unique: true,
29
+ t.index %i[ organization_id person_id role_id ], unique: true,
28
30
  name: :jobshop_role_assignment_user_roles_ckey
29
- t.index [ :organization_id, :role_id, :user_id ], unique: true,
31
+ t.index %i[ organization_id role_id person_id ], unique: true,
30
32
  name: :jobshop_role_assignment_role_users_ckey
31
33
 
32
34
  t.timestamps
33
35
  end
34
36
 
35
- fk_organization_id "jobshop_role_assignments"
36
- foreign_key "jobshop_role_assignments", "jobshop_roles",
37
- [ "organization_id", "role_id" ]
38
- foreign_key "jobshop_role_assignments", "jobshop_users",
39
- [ "organization_id", "user_id" ]
37
+ fk_organization_id :jobshop_role_assignments
38
+ foreign_key :jobshop_role_assignments, :jobshop_roles,
39
+ %i[ organization_id role_id ]
40
+ foreign_key :jobshop_role_assignments, :jobshop_people,
41
+ %i[ organization_id person_id ]
40
42
 
41
43
  create_table :jobshop_abilities, id: :uuid, default: "gen_random_uuid()" do |t|
42
44
  t.uuid :organization_id, null: false
43
45
  t.uuid :resource_id
44
46
  t.string :resource_class, null: false
45
47
  t.integer :action
46
- t.index [ :organization_id, :resource_class, :action, :resource_id ],
48
+ t.index %i[ organization_id resource_class action resource_id ],
47
49
  unique: true, name: :idx_jobshop_abilities_secondary_key
48
50
  end
49
51
 
50
- fk_organization_id "jobshop_abilities"
52
+ fk_organization_id :jobshop_abilities
51
53
  end
52
54
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literals: true
2
+
1
3
  require "jobshop/helpers/migration.rb"
2
4
 
3
- class CreateSessions < ActiveRecord::Migration[5.1]
5
+ class CreateSessions < ActiveRecord::Migration[5.2]
4
6
  include Jobshop::Helpers::Migration
5
7
 
6
8
  def change
@@ -8,14 +10,14 @@ class CreateSessions < ActiveRecord::Migration[5.1]
8
10
  t.uuid :organization_id, null: false
9
11
  t.uuid :user_id, null: false
10
12
  t.string :activation_token, null: false, activation_token: { unique: true }
11
- t.index [ :organization_id, :user_id, :activation_token ], unique: true,
12
- name: "idx_jobshop_sessions_pkey"
13
+ t.index %i[ organization_id user_id activation_token ], unique: true,
14
+ name: :idx_jobshop_sessions_pkey
13
15
  t.timestamps
14
16
  end
15
17
 
16
- idx_table_name_pkey "jobshop_sessions"
17
- fk_organization_id "jobshop_sessions"
18
- foreign_key "jobshop_sessions", "jobshop_users",
19
- [ "organization_id", "user_id" ]
18
+ idx_table_name_pkey :jobshop_sessions
19
+ fk_organization_id :jobshop_sessions
20
+ foreign_key :jobshop_sessions, :jobshop_users,
21
+ %i[ organization_id user_id ]
20
22
  end
21
23
  end
@@ -1,18 +1,20 @@
1
+ # frozen_string_literals: true
2
+
1
3
  require "jobshop/helpers/migration.rb"
2
4
 
3
- class CreateThings < ActiveRecord::Migration[5.1]
5
+ class CreateThings < ActiveRecord::Migration[5.2]
4
6
  include Jobshop::Helpers::Migration
5
7
 
6
8
  def change
7
9
  create_table :jobshop_things, id: false do |t|
8
10
  t.uuid :organization_id, null: false
9
11
  t.uuid :thing_id, null: false, default: "gen_random_uuid()"
10
- t.index [ :organization_id, :thing_id ],
12
+ t.index %i[ organization_id thing_id ],
11
13
  name: :idx_jobshop_things_pkey, unique: true
12
14
 
13
15
  t.uuid :collection_id, null: false
14
16
  t.citext :name
15
- t.index [ :organization_id, :collection_id, :name ], unique: true,
17
+ t.index %i[ organization_id collection_id name ], unique: true,
16
18
  name: :idx_jobshop_organization_id_collection_id_name
17
19
 
18
20
  t.jsonb :custom_fields, null: false, default: "{}"
@@ -27,11 +29,11 @@ class CreateThings < ActiveRecord::Migration[5.1]
27
29
  create_table :jobshop_collections, id: false do |t|
28
30
  t.uuid :organization_id, null: false
29
31
  t.uuid :collection_id, null: false, default: "gen_random_uuid()"
30
- t.index [ :organization_id, :collection_id ], unique: true,
32
+ t.index %i[ organization_id collection_id ], unique: true,
31
33
  name: :idx_jobshop_collections_pkey
32
34
 
33
35
  t.citext :name
34
- t.index [ :organization_id, :name ], unique: true
36
+ t.index %i[ organization_id name ], unique: true
35
37
 
36
38
  t.jsonb :schema, null: false, default: "{}"
37
39
 
@@ -1,17 +1,19 @@
1
+ # frozen_string_literals: true
2
+
1
3
  require "jobshop/helpers/migration.rb"
2
4
 
3
- class CreateRoutingProcesses < ActiveRecord::Migration[5.1]
5
+ class CreateRoutingProcesses < ActiveRecord::Migration[5.2]
4
6
  include Jobshop::Helpers::Migration
5
7
 
6
- def change
8
+ def change # rubocop:disable Metrics/MethodLength
7
9
  create_table :jobshop_routing_processes, id: false do |t|
8
10
  t.uuid :organization_id, null: false
9
11
  t.uuid :routing_process_id, null: false, default: "gen_random_uuid()"
10
- t.index [ :organization_id, :routing_process_id ], unique: true,
12
+ t.index %i[ organization_id routing_process_id ], unique: true,
11
13
  name: "idx_jobshop_routing_processes_pkey"
12
14
 
13
15
  t.uuid :product_id
14
- t.index [ :organization_id, :product_id ], unique: true,
16
+ t.index %i[ organization_id product_id ], unique: true,
15
17
  name: "idx_jobshop_routing_processes_product_id"
16
18
  end
17
19
 
@@ -24,7 +26,7 @@ class CreateRoutingProcesses < ActiveRecord::Migration[5.1]
24
26
  t.uuid :organization_id, null: false
25
27
  t.uuid :routing_process_id, null: false
26
28
  t.uuid :routing_process_instance_id, null: false, default: "gen_random_uuid()"
27
- t.index [ :organization_id, :routing_process_id, :routing_process_instance_id ], unique: true,
29
+ t.index %i[ organization_id routing_process_id routing_process_instance_id ], unique: true,
28
30
  name: "idx_jobshop_routing_process_instances_pkey"
29
31
 
30
32
  t.timestamps
@@ -36,15 +38,15 @@ class CreateRoutingProcesses < ActiveRecord::Migration[5.1]
36
38
  create_table :jobshop_routing_steps, id: false do |t|
37
39
  t.uuid :organization_id, null: false
38
40
  t.uuid :routing_step_id, null: false, default: "gen_random_uuid()"
39
- t.index [ :organization_id, :routing_step_id ], unique: true,
41
+ t.index %i[ organization_id routing_step_id ], unique: true,
40
42
  name: "idx_jobshop_routing_steps_pkey"
41
43
 
42
44
  t.uuid :routing_process_id, null: false
43
- t.index [ :organization_id, :routing_process_id ],
45
+ t.index %i[ organization_id routing_process_id ],
44
46
  name: "idx_jobshop_routing_steps_routing_process_id"
45
47
 
46
48
  t.citext :name
47
- t.index [ :organization_id, :name ]
49
+ t.index %i[ organization_id name ]
48
50
  end
49
51
 
50
52
  idx_table_name_pkey "jobshop_routing_steps"
@@ -1,13 +1,15 @@
1
+ # frozen_string_literals: true
2
+
1
3
  require "jobshop/helpers/migration.rb"
2
4
 
3
- class CreateInspection < ActiveRecord::Migration[5.1]
5
+ class CreateInspections < ActiveRecord::Migration[5.2]
4
6
  include Jobshop::Helpers::Migration
5
7
 
6
- def change
8
+ def change # rubocop:disable Metrics/MethodLength
7
9
  create_table :jobshop_inspection_reports, id: false do |t|
8
10
  t.uuid :organization_id, null: false
9
11
  t.uuid :report_id, null: false, default: "gen_random_uuid()"
10
- t.index [ :organization_id, :report_id ], unique: true,
12
+ t.index %i[ organization_id report_id ], unique: true,
11
13
  name: "idx_jobshop_inspection_reports_pkey"
12
14
 
13
15
  t.timestamps
@@ -21,16 +23,19 @@ class CreateInspection < ActiveRecord::Migration[5.1]
21
23
  t.uuid :report_id, null: false
22
24
  t.uuid :criterion_id, null: false, default: "gen_random_uuid()"
23
25
  t.string :criterion_type, null: false
24
- t.index [ :organization_id, :report_id, :criterion_id, :criterion_type ],
26
+ t.index %i[ organization_id report_id criterion_id criterion_type ],
25
27
  name: "idx_jobshop_inspection_criteria_pkey", unique: true
28
+
26
29
  t.integer :position, null: false
27
- t.index [ :report_id, :position ], unique: true
30
+ t.index %i[ report_id position ], unique: true
28
31
 
29
32
  t.citext :name, null: false
30
- t.index [ :report_id, :name ], unique: true,
33
+ t.index %i[ report_id name ], unique: true,
31
34
  name: "idx_jobshop_inspection_criteria_name"
32
35
  end
33
36
 
37
+ # At what point do Jobshop::Inspection::Criteria::Types
38
+ # become their own relation?
34
39
  execute <<~SQL
35
40
  ALTER TABLE jobshop_inspection_criteria
36
41
  ADD CONSTRAINT valid_criterion_type
@@ -48,7 +53,7 @@ class CreateInspection < ActiveRecord::Migration[5.1]
48
53
  t.uuid :organization_id, null: false
49
54
  t.uuid :report_id, null: false
50
55
  t.integer :position, null: false
51
- t.index [ :organization_id, :report_id, :position ], unique: true,
56
+ t.index %i[ organization_id report_id position ], unique: true,
52
57
  name: "idx_jobshop_inspection_tuples_pkey"
53
58
  end
54
59
 
@@ -61,7 +66,7 @@ class CreateInspection < ActiveRecord::Migration[5.1]
61
66
  t.uuid :criterion_id, null: false
62
67
  t.string :criterion_type, null: false
63
68
  t.integer :position, null: false
64
- t.index [ :organization_id, :report_id, :criterion_id, :criterion_type, :position ],
69
+ t.index %i[ organization_id report_id criterion_id criterion_type position ],
65
70
  name: "idx_jobshop_inspection_results_pkey", unique: true
66
71
 
67
72
  t.decimal :value
@@ -71,10 +76,10 @@ class CreateInspection < ActiveRecord::Migration[5.1]
71
76
  idx_table_name_pkey :jobshop_inspection_results
72
77
  fk_organization_id :jobshop_inspection_results
73
78
  foreign_key :jobshop_inspection_results, :jobshop_inspection_criteria,
74
- [ :organization_id, :report_id, :criterion_id, :criterion_type ],
79
+ %i[ organization_id report_id criterion_id criterion_type ],
75
80
  "DEFERRABLE INITIALLY DEFERRED"
76
81
  foreign_key :jobshop_inspection_results, :jobshop_inspection_tuples,
77
- [ :organization_id, :report_id, :position ],
82
+ %i[ organization_id report_id position ],
78
83
  "DEFERRABLE INITIALLY DEFERRED"
79
84
 
80
85
  create_table :jobshop_inspection_boolean_criteria, id: false do |t|
@@ -82,7 +87,7 @@ class CreateInspection < ActiveRecord::Migration[5.1]
82
87
  t.uuid :report_id, null: false
83
88
  t.uuid :criterion_id, null: false
84
89
  t.string :criterion_type, null: false, default: "Jobshop::Inspection::BooleanCriterion"
85
- t.index [ :organization_id, :report_id, :criterion_id, :criterion_type ],
90
+ t.index %i[ organization_id report_id criterion_id criterion_type ],
86
91
  name: "idx_jobshop_inspection_boolean_criteria_pkey", unique: true
87
92
 
88
93
  t.citext :condition
@@ -98,7 +103,7 @@ class CreateInspection < ActiveRecord::Migration[5.1]
98
103
  fk_organization_id :jobshop_inspection_boolean_criteria
99
104
  foreign_key :jobshop_inspection_boolean_criteria,
100
105
  :jobshop_inspection_criteria,
101
- [ :organization_id, :report_id, :criterion_id, :criterion_type ],
106
+ %i[ organization_id report_id criterion_id criterion_type ],
102
107
  "DEFERRABLE INITIALLY DEFERRED"
103
108
 
104
109
  create_table :jobshop_inspection_limit_criteria, id: false do |t|
@@ -106,7 +111,7 @@ class CreateInspection < ActiveRecord::Migration[5.1]
106
111
  t.uuid :report_id, null: false
107
112
  t.uuid :criterion_id, null: false
108
113
  t.string :criterion_type, null: false, default: "Jobshop::Inspection::LimitCriterion"
109
- t.index [ :organization_id, :report_id, :criterion_id, :criterion_type ],
114
+ t.index %i[ organization_id report_id criterion_id criterion_type ],
110
115
  name: "idx_jobshop_inspection_limit_criteria_pkey", unique: true
111
116
 
112
117
  t.decimal :minimum
@@ -125,7 +130,7 @@ class CreateInspection < ActiveRecord::Migration[5.1]
125
130
  fk_organization_id :jobshop_inspection_limit_criteria
126
131
  foreign_key :jobshop_inspection_limit_criteria,
127
132
  :jobshop_inspection_criteria,
128
- [ :organization_id, :report_id, :criterion_id, :criterion_type ],
133
+ %i[ organization_id report_id criterion_id criterion_type ],
129
134
  "DEFERRABLE INITIALLY DEFERRED"
130
135
 
131
136
  create_table :jobshop_inspection_deviation_criteria, id: false do |t|
@@ -133,7 +138,7 @@ class CreateInspection < ActiveRecord::Migration[5.1]
133
138
  t.uuid :report_id, null: false
134
139
  t.uuid :criterion_id, null: false
135
140
  t.string :criterion_type, null: false, default: "Jobshop::Inspection::DeviationCriterion"
136
- t.index [ :organization_id, :report_id, :criterion_id, :criterion_type ],
141
+ t.index %i[ organization_id report_id criterion_id criterion_type ],
137
142
  name: "idx_jobshop_inspection_deviation_criteria_pkey", unique: true
138
143
 
139
144
  t.decimal :nominal, null: false
@@ -153,7 +158,7 @@ class CreateInspection < ActiveRecord::Migration[5.1]
153
158
  fk_organization_id :jobshop_inspection_deviation_criteria
154
159
  foreign_key :jobshop_inspection_deviation_criteria,
155
160
  :jobshop_inspection_criteria,
156
- [ :organization_id, :report_id, :criterion_id, :criterion_type ],
161
+ %i[ organization_id report_id criterion_id criterion_type ],
157
162
  "DEFERRABLE INITIALLY DEFERRED"
158
163
  end
159
164
  end
@@ -0,0 +1,40 @@
1
+ require "jobshop/helpers/migration.rb"
2
+
3
+ class CreateRFQs < ActiveRecord::Migration[5.2]
4
+ include Jobshop::Helpers::Migration
5
+
6
+ def change
7
+ create_table :jobshop_rfqs, id: false do |t|
8
+ t.uuid :organization_id, null: false
9
+ t.uuid :rfq_id, null: false, default: "gen_random_uuid()"
10
+ t.index %i[ organization_id rfq_id ], unique: true,
11
+ name: "idx_jobshop_rfqs_pkey"
12
+
13
+ t.uuid :company_id, null: true
14
+ t.index %i[ organization_id company_id ], where: "company_id IS NOT NULL"
15
+ t.index %i[ organization_id company_id ], where: "company_id IS NULL",
16
+ name: "idx_jobshop_rfqs_company_is_null"
17
+
18
+ t.string :from
19
+ t.string :subject, null: false
20
+ t.text :content, null: false
21
+
22
+ t.timestamps
23
+ end
24
+
25
+ idx_table_name_pkey "jobshop_rfqs"
26
+ fk_organization_id "jobshop_rfqs"
27
+ foreign_key "jobshop_rfqs", "jobshop_companies",
28
+ [ "organization_id", "company_id" ]
29
+
30
+ create_table :jobshop_rfq_lines, id: false do |t|
31
+ t.uuid :organization_id, null: false
32
+ t.uuid :rfq_id, null: false
33
+ t.uuid :rfq_line_id, null: false, default: "gen_random_uuid()"
34
+ t.index %i[ organization_id rfq_id rfq_line_id ], unique: true,
35
+ name: "idx_jobshop_rfq_lines_pkey"
36
+
37
+ t.timestamps
38
+ end
39
+ end
40
+ end