ronin-db-activerecord 0.1.6 → 0.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog.md +91 -0
  3. data/README.md +49 -1
  4. data/db/migrate/0037_add_created_at_column_to_ronin_ports_table.rb +40 -0
  5. data/db/migrate/0038_add_created_at_column_to_ronin_services_table.rb +40 -0
  6. data/db/migrate/0039_create_ronin_cert_names_table.rb +37 -0
  7. data/db/migrate/0040_create_ronin_cert_issuers_table.rb +52 -0
  8. data/db/migrate/0041_create_ronin_cert_subjects_table.rb +54 -0
  9. data/db/migrate/0042_create_ronin_cert_subject_alt_names_table.rb +42 -0
  10. data/db/migrate/0043_create_ronin_certs_table.rb +61 -0
  11. data/db/migrate/0044_add_cert_id_column_to_ronin_open_ports_table.rb +35 -0
  12. data/db/migrate/0045_create_ronin_notes_table.rb +120 -0
  13. data/db/migrate/0046_create_ronin_web_vulns_table.rb +61 -0
  14. data/db/migrate/0047_create_ronin_phone_numbers_table.rb +47 -0
  15. data/db/migrate/0048_create_ronin_street_addresses_table.rb +46 -0
  16. data/db/migrate/0049_create_ronin_people_table.rb +48 -0
  17. data/db/migrate/0050_create_ronin_personal_connections_table.rb +48 -0
  18. data/db/migrate/0051_create_ronin_personal_phone_numbers_table.rb +48 -0
  19. data/db/migrate/0052_create_ronin_personal_email_addresses_table.rb +45 -0
  20. data/db/migrate/0053_create_ronin_personal_street_addresses_table.rb +47 -0
  21. data/db/migrate/0054_add_type_column_to_ronin_organizations_table.rb +33 -0
  22. data/db/migrate/0055_add_parent_id_column_to_ronin_organizations_table.rb +43 -0
  23. data/db/migrate/0056_create_ronin_organization_departments_table.rb +59 -0
  24. data/db/migrate/0057_create_ronin_organization_members_table.rb +62 -0
  25. data/db/migrate/0058_create_ronin_organization_customers_table.rb +52 -0
  26. data/db/migrate/0059_create_ronin_organization_phone_numbers_table.rb +47 -0
  27. data/db/migrate/0060_create_ronin_organization_email_addresses_table.rb +45 -0
  28. data/db/migrate/0061_create_ronin_organization_street_addresses_table.rb +47 -0
  29. data/db/migrate/0062_add_source_ip_column_to_http_requests_table.rb +30 -0
  30. data/db/migrate/0063_create_ronin_dns_queries_table.rb +41 -0
  31. data/db/migrate/0064_create_ronin_dns_records_table.rb +42 -0
  32. data/db/migrate/0065_create_ronin_organization_host_names_table.rb +43 -0
  33. data/db/migrate/0066_create_ronin_organization_ip_addresses_table.rb +43 -0
  34. data/gemspec.yml +1 -1
  35. data/lib/ronin/db/address.rb +1 -1
  36. data/lib/ronin/db/advisory.rb +66 -1
  37. data/lib/ronin/db/arch.rb +1 -1
  38. data/lib/ronin/db/asn.rb +15 -1
  39. data/lib/ronin/db/cert.rb +501 -0
  40. data/lib/ronin/db/cert_issuer.rb +78 -0
  41. data/lib/ronin/db/cert_name.rb +107 -0
  42. data/lib/ronin/db/cert_organization.rb +127 -0
  43. data/lib/ronin/db/cert_subject.rb +81 -0
  44. data/lib/ronin/db/cert_subject_alt_name.rb +88 -0
  45. data/lib/ronin/db/credential.rb +10 -1
  46. data/lib/ronin/db/dns_query.rb +98 -0
  47. data/lib/ronin/db/dns_record.rb +76 -0
  48. data/lib/ronin/db/email_address.rb +139 -1
  49. data/lib/ronin/db/host_name.rb +45 -1
  50. data/lib/ronin/db/host_name_ip_address.rb +1 -1
  51. data/lib/ronin/db/http_header_name.rb +1 -1
  52. data/lib/ronin/db/http_query_param.rb +1 -1
  53. data/lib/ronin/db/http_query_param_name.rb +1 -1
  54. data/lib/ronin/db/http_request.rb +13 -1
  55. data/lib/ronin/db/http_request_header.rb +1 -1
  56. data/lib/ronin/db/http_response.rb +1 -1
  57. data/lib/ronin/db/http_response_header.rb +1 -1
  58. data/lib/ronin/db/ip_address.rb +46 -1
  59. data/lib/ronin/db/ip_address_mac_address.rb +1 -1
  60. data/lib/ronin/db/mac_address.rb +28 -1
  61. data/lib/ronin/db/migrations.rb +1 -1
  62. data/lib/ronin/db/model/has_name.rb +18 -1
  63. data/lib/ronin/db/model/has_unique_name.rb +1 -1
  64. data/lib/ronin/db/model/importable.rb +1 -1
  65. data/lib/ronin/db/model/last_scanned_at.rb +1 -1
  66. data/lib/ronin/db/model.rb +1 -1
  67. data/lib/ronin/db/models.rb +44 -2
  68. data/lib/ronin/db/note.rb +199 -0
  69. data/lib/ronin/db/open_port.rb +104 -3
  70. data/lib/ronin/db/organization.rb +237 -3
  71. data/lib/ronin/db/organization_customer.rb +73 -0
  72. data/lib/ronin/db/organization_department.rb +97 -0
  73. data/lib/ronin/db/organization_email_address.rb +66 -0
  74. data/lib/ronin/db/organization_host_name.rb +65 -0
  75. data/lib/ronin/db/organization_ip_address.rb +65 -0
  76. data/lib/ronin/db/organization_member.rb +158 -0
  77. data/lib/ronin/db/organization_phone_number.rb +66 -0
  78. data/lib/ronin/db/organization_street_address.rb +66 -0
  79. data/lib/ronin/db/os.rb +35 -1
  80. data/lib/ronin/db/os_guess.rb +1 -1
  81. data/lib/ronin/db/password.rb +84 -1
  82. data/lib/ronin/db/person.rb +455 -0
  83. data/lib/ronin/db/personal_connection.rb +110 -0
  84. data/lib/ronin/db/personal_email_address.rb +66 -0
  85. data/lib/ronin/db/personal_phone_number.rb +76 -0
  86. data/lib/ronin/db/personal_street_address.rb +66 -0
  87. data/lib/ronin/db/phone_number.rb +330 -0
  88. data/lib/ronin/db/port.rb +110 -1
  89. data/lib/ronin/db/service.rb +130 -1
  90. data/lib/ronin/db/service_credential.rb +1 -1
  91. data/lib/ronin/db/software.rb +37 -1
  92. data/lib/ronin/db/software_vendor.rb +1 -1
  93. data/lib/ronin/db/street_address.rb +340 -0
  94. data/lib/ronin/db/url.rb +37 -1
  95. data/lib/ronin/db/url_query_param.rb +1 -1
  96. data/lib/ronin/db/url_query_param_name.rb +9 -1
  97. data/lib/ronin/db/url_scheme.rb +1 -1
  98. data/lib/ronin/db/user_name.rb +58 -1
  99. data/lib/ronin/db/vulnerability.rb +1 -1
  100. data/lib/ronin/db/web_credential.rb +1 -1
  101. data/lib/ronin/db/web_vuln.rb +348 -0
  102. metadata +57 -2
@@ -0,0 +1,120 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Creates the `ronin_notes` table.
25
+ #
26
+ class CreateRoninNotesTable < ActiveRecord::Migration[7.0]
27
+
28
+ def change
29
+ create_table :ronin_notes, if_not_exists: true do |t|
30
+ t.text :body, null: false
31
+ t.timestamps
32
+
33
+ t.references :mac_address, null: true,
34
+ foreign_key: {
35
+ to_table: :ronin_mac_addresses
36
+ }
37
+
38
+ t.references :ip_address, null: true,
39
+ foreign_key: {
40
+ to_table: :ronin_ip_addresses
41
+ }
42
+
43
+ t.references :host_name, null: true,
44
+ foreign_key: {
45
+ to_table: :ronin_host_names
46
+ }
47
+
48
+ t.references :port, null: true,
49
+ foreign_key: {
50
+ to_table: :ronin_ports
51
+ }
52
+
53
+ t.references :service, null: true,
54
+ foreign_key: {
55
+ to_table: :ronin_services
56
+ }
57
+
58
+ t.references :open_port, null: true,
59
+ foreign_key: {
60
+ to_table: :ronin_open_ports
61
+ }
62
+
63
+ t.references :cert, null: true,
64
+ foreign_key: {
65
+ to_table: :ronin_certs
66
+ }
67
+
68
+ t.references :url, null: true,
69
+ foreign_key: {
70
+ to_table: :ronin_urls
71
+ }
72
+
73
+ t.references :user_name, null: true,
74
+ foreign_key: {
75
+ to_table: :ronin_user_names
76
+ }
77
+
78
+ t.references :email_address, null: true,
79
+ foreign_key: {
80
+ to_table: :ronin_email_addresses
81
+ }
82
+
83
+ t.references :password, null: true,
84
+ foreign_key: {
85
+ to_table: :ronin_passwords
86
+ }
87
+
88
+ t.references :credential, null: true,
89
+ foreign_key: {
90
+ to_table: :ronin_credentials
91
+ }
92
+
93
+ t.references :advisory, null: true,
94
+ foreign_key: {
95
+ to_table: :ronin_advisories
96
+ }
97
+
98
+ t.references :street_address, null: true,
99
+ foreign_key: {
100
+ to_table: :ronin_street_addresses
101
+ }
102
+
103
+ t.references :phone_number, null: true,
104
+ foreign_key: {
105
+ to_table: :ronin_phone_numbers
106
+ }
107
+
108
+ t.references :person, null: true,
109
+ foreign_key: {
110
+ to_table: :ronin_people
111
+ }
112
+
113
+ t.references :organization, null: true,
114
+ foreign_key: {
115
+ to_table: :ronin_organizations
116
+ }
117
+ end
118
+ end
119
+
120
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Creates the `ronin_web_vulns` table.
25
+ #
26
+ class CreateRoninWebVulnsTable < ActiveRecord::Migration[7.0]
27
+
28
+ def change
29
+ create_table :ronin_web_vulns, if_not_exists: true do |t|
30
+ t.string :type, length: 13, null: false
31
+ t.references :url, null: false,
32
+ foreign_key: {
33
+ to_table: :ronin_urls
34
+ }
35
+
36
+ t.string :query_param, length: 225, null: true
37
+ t.string :header_name, length: 225, null: true
38
+ t.string :cookie_param, length: 225, null: true
39
+ t.string :form_param, length: 225, null: true
40
+
41
+ t.string :request_method, length: 9, null: false
42
+ t.string :lfi_os, length: 7, null: true
43
+ t.integer :lfi_depth, null: true
44
+ t.string :lfi_filter_bypass, length: 9, null: true
45
+ t.string :rfi_script_lang, length: 11, null: true
46
+ t.string :rfi_filter_bypass, length: 13, null: true
47
+ t.string :ssti_escape_type, length: 26, null: true
48
+
49
+ t.boolean :sqli_escape_quote, null: true
50
+ t.boolean :sqli_escape_parens, null: true
51
+ t.boolean :sqli_terminate, null: true
52
+
53
+ t.string :command_injection_escape_quote, null: true
54
+ t.string :command_injection_escape_operator, null: true
55
+ t.string :command_injection_terminator, null: true
56
+
57
+ t.index [:type, :query_param, :header_name, :cookie_param, :form_param, :url], unique: true, name: 'index_ronin_url_web_vulns_unique'
58
+ end
59
+ end
60
+
61
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Creates the `ronin_phone_number` table.
25
+ #
26
+ class CreateRoninPhoneNumbersTable < ActiveRecord::Migration[7.0]
27
+
28
+ def change
29
+ create_table :ronin_phone_numbers, if_not_exists: true do |t|
30
+ t.string :number, null: false, length: 17
31
+
32
+ t.string :country_code, null: true, length: 3
33
+ t.string :area_code, null: true, length: 3
34
+ t.string :prefix, null: false, length: 3
35
+ t.string :line_number, null: false, length: 4
36
+
37
+ t.datetime :created_at, null: false
38
+
39
+ t.index :number, unique: true
40
+ t.index :country_code
41
+ t.index :area_code
42
+ t.index :prefix
43
+ t.index :line_number
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Creates the `ronin_street_addresses` table.
25
+ #
26
+ class CreateRoninStreetAddressesTable < ActiveRecord::Migration[7.0]
27
+
28
+ def change
29
+ create_table :ronin_street_addresses, if_not_exists: true do |t|
30
+ t.string :address, null: false, length: 46
31
+ t.string :city, null: false, length: 58
32
+ t.string :state, null: true, length: 13
33
+ t.string :zipcode, null: true, length: 10
34
+ t.string :country, null: false, length: 56
35
+ t.datetime :created_at, null: false
36
+
37
+ t.index [:address, :city, :state, :zipcode, :country], unique: true,
38
+ name: :index_ronin_street_addresses_table_unique
39
+ t.index :city
40
+ t.index :state
41
+ t.index :zipcode
42
+ t.index :country
43
+ end
44
+ end
45
+
46
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Creates the `ronin_people` table.
25
+ #
26
+ class CreateRoninPeopleTable < ActiveRecord::Migration[7.0]
27
+
28
+ def change
29
+ create_table :ronin_people, if_not_exists: true do |t|
30
+ t.string :full_name, null: false
31
+ t.string :prefix, null: true, length: 6
32
+ t.string :first_name, null: false
33
+ t.string :middle_name, null: true
34
+ t.string :middle_initial, null: true, length: 1
35
+ t.string :last_name, null: true
36
+ t.string :suffix, null: true, length: 3
37
+
38
+ t.index :full_name, unique: true
39
+ t.index :prefix
40
+ t.index :first_name
41
+ t.index :middle_name
42
+ t.index :middle_initial
43
+ t.index :last_name
44
+ t.index :suffix
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Creates the `ronin_personal_connections` table.
25
+ #
26
+ class CreateRoninPersonalConnectionsTable < ActiveRecord::Migration[7.0]
27
+
28
+ def change
29
+ create_table :ronin_personal_connections, if_not_exists: true do |t|
30
+ t.string :type, null: true, length: 13
31
+
32
+ t.references :person, null: false,
33
+ foreign_key: {
34
+ to_table: :ronin_people
35
+ }
36
+ t.references :other_person, null: true,
37
+ foreign_key: {
38
+ to_table: :ronin_people
39
+ }
40
+ t.datetime :created_at, null: false
41
+
42
+ t.index :type
43
+ t.index [:type, :person_id, :other_person_id], unique: true,
44
+ name: :index_ronin_personal_connections_table_unique
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Creates the `ronin_personal_phone_numbers` table.
25
+ #
26
+ class CreateRoninPersonalPhoneNumbersTable < ActiveRecord::Migration[7.0]
27
+
28
+ def change
29
+ create_table :ronin_personal_phone_numbers, if_not_exists: true do |t|
30
+ t.string :type, length: 4
31
+
32
+ t.references :person, null: false,
33
+ foreign_key: {
34
+ to_table: :ronin_people
35
+ }
36
+ t.references :phone_number, null: true,
37
+ foreign_key: {
38
+ to_table: :ronin_phone_numbers
39
+ }
40
+ t.datetime :created_at, null: false
41
+
42
+ t.index :type
43
+ t.index [:type, :person_id, :phone_number_id], unique: true,
44
+ name: :index_ronin_personal_phone_numbers_table_unique
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Creates the `ronin_personal_email_addresses` table.
25
+ #
26
+ class CreateRoninPersonalEmailAddressesTable < ActiveRecord::Migration[7.0]
27
+
28
+ def change
29
+ create_table :ronin_personal_email_addresses, if_not_exists: true do |t|
30
+ t.references :person, null: false,
31
+ foreign_key: {
32
+ to_table: :ronin_people
33
+ }
34
+ t.references :email_address, null: true,
35
+ foreign_key: {
36
+ to_table: :ronin_email_addresses
37
+ }
38
+ t.datetime :created_at, null: false
39
+
40
+ t.index [:person_id, :email_address_id], unique: true,
41
+ name: :index_ronin_personal_email_addresses_table_unique
42
+ end
43
+ end
44
+
45
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Creates the `ronin_personal_street_addresses` table.
25
+ #
26
+ class CreateRoninPersonalStreetAddressesTable < ActiveRecord::Migration[7.0]
27
+
28
+ def change
29
+ create_table :ronin_personal_street_addresses, if_not_exists: true do |t|
30
+ t.references :person, null: false,
31
+ foreign_key: {
32
+ to_table: :ronin_people
33
+ }
34
+
35
+ t.references :street_address, null: false,
36
+ foreign_key: {
37
+ to_table: :ronin_street_addresses
38
+ }
39
+
40
+ t.datetime :created_at, null: false
41
+
42
+ t.index [:person_id, :street_address_id], unique: true,
43
+ name: :index_ronin_personal_street_addresses_table_unique
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Adds the `type` column to the `ronin_organizations` table.
25
+ #
26
+ class AddTypeColumnToRoninOrganizationsTable < ActiveRecord::Migration[7.0]
27
+
28
+ def change
29
+ add_column :ronin_organizations, :type, :string, null: true, length: 12
30
+ add_index :ronin_organizations, :type
31
+ end
32
+
33
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Adds the `parent_id` column to the `ronin_organizations` table.
25
+ #
26
+ class AddParentIdColumnToRoninOrganizationsTable < ActiveRecord::Migration[7.0]
27
+
28
+ def up
29
+ add_reference :ronin_organizations, :parent, null: true,
30
+ foreign_key: {
31
+ to_table: :ronin_organizations
32
+ }
33
+
34
+ add_index :ronin_organizations, [:type, :name, :parent_id], unique: true
35
+ end
36
+
37
+ def down
38
+ remove_index :ronin_organizations, [:type, :name, :parent_id]
39
+
40
+ remove_reference :ronin_organizations, :organization
41
+ end
42
+
43
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Create the `ronin_organization_departments` table.
25
+ #
26
+ class CreateRoninOrganizationDepartmentsTable < ActiveRecord::Migration[7.0]
27
+
28
+ def change
29
+ create_table :ronin_organization_departments, if_not_exists: true do |t|
30
+ t.string :name, null: false
31
+
32
+ t.references :organization, null: false,
33
+ foreign_key: {
34
+ to_table: :ronin_organizations
35
+ }
36
+ t.references :street_address, null: true,
37
+ foreign_key: {
38
+ to_table: :ronin_street_addresses
39
+ }
40
+ t.references :phone_number, null: true,
41
+ foreign_key: {
42
+ to_table: :ronin_phone_numbers
43
+ }
44
+ t.references :email_address, null: true,
45
+ foreign_key: {
46
+ to_table: :ronin_email_addresses
47
+ }
48
+ t.references :parent_department, null: true,
49
+ foreign_key: {
50
+ to_table: :ronin_organization_departments
51
+ }
52
+ t.datetime :created_at, null: false
53
+
54
+ t.index [:name, :organization_id], unique: true,
55
+ name: :index_ronin_organization_departments_table_unique
56
+ end
57
+ end
58
+
59
+ end