Skip to content

Commit 8952a83

Browse files
committed
db set up for document types
1 parent 6732fc9 commit 8952a83

9 files changed

+117
-1
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class CreateDocumentTypes < ActiveRecord::Migration[5.2]
2+
def change
3+
create_table :document_types do |t|
4+
t.string :name
5+
t.references :document, foreign_key: true
6+
t.timestamps
7+
end
8+
end
9+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddDescriptionToDocumentTypes < ActiveRecord::Migration[5.2]
2+
def change
3+
add_column :document_types, :description, :string
4+
end
5+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class RemoveDocumentFromDocumentTypes < ActiveRecord::Migration[5.2]
2+
def change
3+
remove_column :document_types, :document_id, :bigint
4+
end
5+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddDocumentTypeToDocuments < ActiveRecord::Migration[5.2]
2+
def change
3+
add_reference :documents, :document_type, foreign_key: true
4+
end
5+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddUserRefToDocumentTypes < ActiveRecord::Migration[5.2]
2+
def change
3+
add_reference :document_types, :user, foreign_key: true
4+
end
5+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddStatusToDocumentTypes < ActiveRecord::Migration[5.2]
2+
def change
3+
add_column :document_types, :status, :string
4+
end
5+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class ChangeDocumentTypeDescriptionToText < ActiveRecord::Migration[5.2]
2+
def change
3+
change_column :document_types, :description, :text
4+
end
5+
end

db/schema.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 2023_12_11_184004) do
13+
ActiveRecord::Schema.define(version: 2024_04_10_113954) do
1414

1515
# These are extensions that must be enabled in order to support this database
1616
enable_extension "plpgsql"
@@ -161,6 +161,16 @@
161161
t.index ["updated"], name: "ix__document_meta_updated"
162162
end
163163

164+
create_table "document_types", force: :cascade do |t|
165+
t.string "name"
166+
t.datetime "created_at", null: false
167+
t.datetime "updated_at", null: false
168+
t.text "description"
169+
t.bigint "user_id"
170+
t.string "status"
171+
t.index ["user_id"], name: "index_document_types_on_user_id"
172+
end
173+
164174
create_table "document_uri", id: :serial, force: :cascade do |t|
165175
t.datetime "created", default: -> { "now()" }, null: false
166176
t.datetime "updated", default: -> { "now()" }, null: false
@@ -191,6 +201,8 @@
191201
t.string "crawler_server"
192202
t.string "text_version"
193203
t.boolean "ota_sourced", default: false
204+
t.bigint "document_type_id"
205+
t.index ["document_type_id"], name: "index_documents_on_document_type_id"
194206
t.index ["service_id"], name: "index_documents_on_service_id"
195207
t.index ["user_id"], name: "index_documents_on_user_id"
196208
end
@@ -483,7 +495,9 @@
483495
add_foreign_key "document_comments", "documents"
484496
add_foreign_key "document_comments", "users"
485497
add_foreign_key "document_meta", "document", name: "fk__document_meta__document_id__document"
498+
add_foreign_key "document_types", "users"
486499
add_foreign_key "document_uri", "document", name: "fk__document_uri__document_id__document"
500+
add_foreign_key "documents", "document_types"
487501
add_foreign_key "documents", "services"
488502
add_foreign_key "documents", "users"
489503
add_foreign_key "featurecohort_feature", "feature", name: "fk__featurecohort_feature__feature_id__feature", on_delete: :cascade

lib/tasks/document_types.rake

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# frozen_string_literal: true
2+
3+
TYPES = {
4+
"Terms of Service" => "concerns end user's service usage",
5+
"Privacy Policy" => "concerns end user's personal data",
6+
"Imprint" => "concerns identification of content author and hosting service for official inquiries",
7+
"Trackers Policy" => "concerns all tracking technologies, including cookies, session storage, fingerprints, etc.",
8+
"Developer Terms" => "concerns APIs and programmatic access to content",
9+
"Community Guidelines" => "concerns public behaviour",
10+
"Deceased Users" => "concerns the handling of information of a deceased individual",
11+
"Acceptable Use Policy" => "concerns acceptable and unacceptable usage",
12+
"Restricted Use Policy" => "concerns restrictions on specific usage",
13+
"Commercial Terms" => "concerns business or commercial usage",
14+
"Copyright Claims Policy" => "addresses how copyright complaints (DMCA, etc.) will be handled",
15+
"Law Enforcement Guidelines" => "concerns account records access",
16+
"Human Rights Policy" => "concerns human rights",
17+
"In-App Purchases Policy" => "concerns usage of in-app purchases and other virtual goods",
18+
"Review Guidelines" => "concerns the review process of provided content",
19+
"Brand Guidelines" => "concerns usage of the service provider's brand",
20+
"Quality Guidelines" => "concerns the quality of content produced by means of the service",
21+
"Data Controller Agreement" => "concerns end user's personal data by data controllers (in the sense of GDPR)",
22+
"Data Processor Agreement" => "concerns the status of the data processor (in the sense of GDPR) for the service provider",
23+
"User Consent Policy" => "concerns user consent collection and storage by data controllers (in the sense of GDPR)",
24+
"Closed Captioning Policy" => "concerns closed captioning on streamed content",
25+
"Seller Warranty" => "concerns protection of end users that act as sellers",
26+
"Single Sign-On Policy" => "concerns connecting user accounts to other services",
27+
"Vulnerability Disclosure Policy" => "concerns how to report a security vulnerability or issue",
28+
"Live Policy" => "concerns end user's live service usage",
29+
"Complaints Policy" => "concerns how generic complaints will be handled",
30+
"Conditions of Carriage" => "concerns benefits and limitations associated with the transportation being provided by transportation operators (airlines, buses, railways, etc.)",
31+
"General Conditions of Sale" => "concerns the warranty, delivery, return of goods or services bought through a monetary transaction",
32+
"Marketplace Buyers Conditions" => "concerns buying through a monetary transaction goods or services offered by sellers other than the marketplace itself",
33+
"Marketplace Sellers Conditions" => "concerns selling through a monetary transaction goods or services to buyers other than the marketplace itself",
34+
"Frequently Asked Questions" => "frequently asked questions about the service, its policies",
35+
"Merged" => "documents that have been merged",
36+
"Coporate Social Responsibility" => "concerns practices integrating social, environmental and profit-related considerations",
37+
"Social Media Policy" => "service provider guidance on how employees should act on social media",
38+
"Uniform Disclosure" => "used to disclose certain information to end users",
39+
"Affiliate Disclosure" =>
40+
"statement informing users that companies compensate affiliates for promoting, reviewing, or recommending their products or services",
41+
"Safety Guidelines" => "service provider protocols to ensure online safety",
42+
"Telephone Communication Guidelines" => "restrictions on telephone solicitations (i.e. telemarketing) and the use of automated phone equipment",
43+
"Records Keeping Policy" => "policies in handling of user records in the event of bankruptcy or data transfer",
44+
"Service Level Agreement" => "outlines a specific commitment between a service provider and a client",
45+
"Legal Information" => "documentation covering miscellaneous policies, notices, and disclaimers",
46+
"Policy" => "generic policies not included in privacy policy coverage",
47+
"About" => "generic information pages",
48+
"Miscellaneous Agreement" => "various agreements published by the service",
49+
"Ranking Parameters Description" => "concerns search engine or service provider's parameters determining ranking and the reasons for their relative importance",
50+
"Premium Partner Conditions" => "concerns sellers' eligibility criteria, limitations and benefits of a privileged seller status programme",
51+
"Platform to Business Notice" => "concerns complaints handling, mediation, transparency and other rights and information mandated by the P2B regulation",
52+
"Business Mediation Policy" => "concerns business users' eligibility and process of mediation after internal complaints handling failed",
53+
"Business Privacy Policy" => "concerns personal data of business users and of people acting on their behalf"
54+
}.freeze
55+
56+
namespace :document_types do
57+
desc 'Create document types'
58+
task create_document_types: :environment do
59+
TYPES.each do |key, value|
60+
DocumentType.create!(name: key, description: value, status: 'approved')
61+
end
62+
end
63+
end

0 commit comments

Comments
 (0)