Instructions for creating the database and migrating written

This commit is contained in:
Jez Caudle 2025-06-19 16:16:16 +00:00
parent dcc7059616
commit 17f43a640a
4 changed files with 40 additions and 21 deletions

View File

@ -38,6 +38,25 @@ CREATE USER 'caf'@'%' IDENTIFIED BY 'caf_password';
CREATE DATABASE cafdb CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_bin'; CREATE DATABASE cafdb CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_bin';
GRANT ALL PRIVILEGES ON cafdb.* TO 'caf'; GRANT ALL PRIVILEGES ON cafdb.* TO 'caf';
FLUSH PRIVILEGES; FLUSH PRIVILEGES;
exit;
VISUAL="/usr/bin/vi" bin/rails credentials:edit
production:
database:
username: caf
password: caf_password
# database.yml
production:
<<: *default
database: cafdb
username: <%= Rails.application.credentials.dig(:production, :database, :username) %>
password: <%= Rails.application.credentials.dig(:production, :database, :password) %>
rails db:migrate
``` ```
Welcome to the Hidden Agenda Ltd CAF tool to help you get organised to become National Cyber Security Centre "Cyber Assessment Framework" (CAF) compliant. Welcome to the Hidden Agenda Ltd CAF tool to help you get organised to become National Cyber Security Centre "Cyber Assessment Framework" (CAF) compliant.

View File

@ -1 +1 @@
0wlK+j+11NIKe85Pfu3w0OdiLVM6fawzZlFSWnvy5fUqRC0A6dVV90yDOfPJh5QEFcvH0Yxe6KcWElZE3ZnYgHWJS9UspLfICs6W+hvNfoUoHW8jyO7fkwcj85RknNrjV+j+XavDFhSRk8wFhQDdLyH4DZrwVRJlCACikuBNcZKvrhe7OvgXvpzKukV4w8lm2MAV0onBSmqBNYv4/24blLb9rIJ17EJVS7TLTccq+fHcQzHT6qZHxRqT/AaRXWaCdoa356j35pmQcwjcaX0gfss9fQVf4zuk7BZqsGrQY7rxgyFsnmdaM6uaK6E8R9tiZjQweJkBOGqlTSZRfEIzdhNwY6FpCZF2xRjOscFOP74Qlbdt5CYNBRMZZM1Dfb3unfeiPj+TOqxKCvYrgqxINwkwe2R8FduyFej4--AYr+gbb69YPkX87U--cM9+bFKTYD1vwbH5k0gnYQ== WLheIIr1QZTYxze029v8Dy0jL2MB1cvb2ARIh50xWImZ/9LHwFzvUMFIk6ThNBNmnvuXVyRgKtuqwFgTRQSaEQRJrO+5Phi1U0+kvqRPGMet5pE1Pmh89hvhDjc7mHgoSSLCATr3gjP/NDtO7qfv1PKElOko5EOSQYWpamo/O1nHB+NUkLVf1cxgIMBOLRqR58dHdv29s/KKjyuJRlV81mx4eqxxGLEIZie1Luhz6TwMg5VNziO3T/N9T/+WOsBdzWxSWhs2IPFpQ7KrBKp+1OdEoxz+ZDmbBPeEamVdF8cv22LbBBsYuxO/HjRDQHz6/MJv+acjA/YMbGdtGrh63tIurnvek/8n+IXBhBqEgND+YghSCr241atcJFWgIle7r6SC7pxDMEVBhwZ3fdxN8nGN/LUNyH/1I2Z6rSndPwNA5kIo1n6DMgg6tm1KsoWcXzIGlSn4dBp2iJaNrRxNd7bo0XzLn6M/XETceloqxuwvQnj/JbFLFHopmn6Ef7ka05AE+mk1pLLTM7pZkydW7WnkIPpjy81qgktxE3OFe8eZ/xEAGynJ+JSdqxSAXR5xbfxO99rtuALzFl9Nn/FgzA==--APubURaGESknyAqI--/W2j15WLWCyIBgfe9DwLKQ==

View File

@ -14,19 +14,19 @@ default: &default
encoding: utf8mb4 encoding: utf8mb4
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: caf username: caf
password: password password: caf_password
host: localhost host: localhost
development: development:
<<: *default <<: *default
database: caf database: cafdb
# Warning: The database defined as "test" will be erased and # Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake". # re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production. # Do not set this db to the same as development or production.
test: test:
<<: *default <<: *default
database: caf_test database: cafdb_test
# As with config/credentials.yml, you never want to store sensitive information, # As with config/credentials.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is # like your database password, in your source code. If your source code is
@ -50,6 +50,6 @@ test:
# #
production: production:
<<: *default <<: *default
database: caf_production database: cafdb
username: caf username: <%= Rails.application.credentials.dig(:production, :database, :username) %>
password: <%= ENV["CAF_HIDDENAGENDA_LTD_UK_DATABASE_PASSWORD"] %> password: <%= Rails.application.credentials.dig(:production, :database, :password) %>

28
db/schema.rb generated
View File

@ -10,8 +10,8 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2024_04_25_091331) do ActiveRecord::Schema[8.0].define(version: 2024_04_25_091331) do
create_table "action_text_rich_texts", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| create_table "action_text_rich_texts", charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.string "name", null: false t.string "name", null: false
t.text "body", size: :long t.text "body", size: :long
t.string "record_type", null: false t.string "record_type", null: false
@ -21,7 +21,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_04_25_091331) do
t.index ["record_type", "record_id", "name"], name: "index_action_text_rich_texts_uniqueness", unique: true t.index ["record_type", "record_id", "name"], name: "index_action_text_rich_texts_uniqueness", unique: true
end end
create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.string "name", null: false t.string "name", null: false
t.string "record_type", null: false t.string "record_type", null: false
t.bigint "record_id", null: false t.bigint "record_id", null: false
@ -31,7 +31,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_04_25_091331) do
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
end end
create_table "active_storage_blobs", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| create_table "active_storage_blobs", charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.string "key", null: false t.string "key", null: false
t.string "filename", null: false t.string "filename", null: false
t.string "content_type" t.string "content_type"
@ -43,13 +43,13 @@ ActiveRecord::Schema[7.1].define(version: 2024_04_25_091331) do
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
end end
create_table "active_storage_variant_records", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| create_table "active_storage_variant_records", charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.bigint "blob_id", null: false t.bigint "blob_id", null: false
t.string "variation_digest", null: false t.string "variation_digest", null: false
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
end end
create_table "cafs", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| create_table "cafs", charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.bigint "company_id", null: false t.bigint "company_id", null: false
t.string "name" t.string "name"
t.text "description" t.text "description"
@ -58,20 +58,20 @@ ActiveRecord::Schema[7.1].define(version: 2024_04_25_091331) do
t.index ["company_id"], name: "index_cafs_on_company_id" t.index ["company_id"], name: "index_cafs_on_company_id"
end end
create_table "companies", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| create_table "companies", charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.string "name" t.string "name"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
end end
create_table "companies_users", id: false, charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| create_table "companies_users", id: false, charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.bigint "user_id" t.bigint "user_id"
t.bigint "company_id" t.bigint "company_id"
t.index ["company_id"], name: "index_companies_users_on_company_id" t.index ["company_id"], name: "index_companies_users_on_company_id"
t.index ["user_id"], name: "index_companies_users_on_user_id" t.index ["user_id"], name: "index_companies_users_on_user_id"
end end
create_table "objectives", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| create_table "objectives", charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.bigint "caf_id", null: false t.bigint "caf_id", null: false
t.string "name" t.string "name"
t.text "description" t.text "description"
@ -80,7 +80,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_04_25_091331) do
t.index ["caf_id"], name: "index_objectives_on_caf_id" t.index ["caf_id"], name: "index_objectives_on_caf_id"
end end
create_table "principles", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| create_table "principles", charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.bigint "objective_id", null: false t.bigint "objective_id", null: false
t.string "name" t.string "name"
t.text "description" t.text "description"
@ -90,7 +90,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_04_25_091331) do
t.index ["objective_id"], name: "fk_rails_7b57179db6" t.index ["objective_id"], name: "fk_rails_7b57179db6"
end end
create_table "subprincipleitemgroups", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| create_table "subprincipleitemgroups", charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.bigint "subprinciple_id", null: false t.bigint "subprinciple_id", null: false
t.string "kind" t.string "kind"
t.datetime "created_at", null: false t.datetime "created_at", null: false
@ -99,7 +99,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_04_25_091331) do
t.index ["subprinciple_id"], name: "index_subprincipleitemgroups_on_subprinciple_id" t.index ["subprinciple_id"], name: "index_subprincipleitemgroups_on_subprinciple_id"
end end
create_table "subprincipleitems", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| create_table "subprincipleitems", charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.bigint "subprincipleitemgroup_id", null: false t.bigint "subprincipleitemgroup_id", null: false
t.text "description" t.text "description"
t.boolean "affirmative", default: false t.boolean "affirmative", default: false
@ -108,7 +108,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_04_25_091331) do
t.index ["subprincipleitemgroup_id"], name: "index_subprincipleitems_on_subprincipleitemgroup_id" t.index ["subprincipleitemgroup_id"], name: "index_subprincipleitems_on_subprincipleitemgroup_id"
end end
create_table "subprinciples", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| create_table "subprinciples", charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.bigint "principle_id", null: false t.bigint "principle_id", null: false
t.string "name" t.string "name"
t.text "description" t.text "description"
@ -118,7 +118,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_04_25_091331) do
t.index ["principle_id"], name: "index_subprinciples_on_principle_id" t.index ["principle_id"], name: "index_subprinciples_on_principle_id"
end end
create_table "users", charset: "utf8mb4", collation: "utf8mb4_general_ci", force: :cascade do |t| create_table "users", charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.string "email", default: "", null: false t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false t.string "encrypted_password", default: "", null: false
t.string "reset_password_token" t.string "reset_password_token"