mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
Records integrity: history, nightly backup and check, records package
AC 120-78B chapter 3:
- Every change to logbook entries, sub-components, signatures, inspection
records, AD compliance, major records, W&B, components, squawks and
documents is kept as a RecordVersion (who, IP, when, field changes),
hash-chained per aircraft; versions can't be edited or deleted. Shown on
each logbook entry and in Activity -> Record history
- Nightly job: SQLite online-backup copy to storage/backups, verified
(integrity_check + record counts), pruned to the configured number; then
an integrity check of the history chains and every signature's seal and
fingerprint. Results on Admin -> About ("Back up and check now"); admins
are emailed on failure
- Software versions recorded (first/last seen) on Admin -> About
- Records package (Access & Sharing): logbook entries PDF with signatures,
signatures.csv, record-history.csv, self-contained status report HTML,
the .sam.zip, and a README, for the FAA/NTSB or a buyer
- Legacy (paper) records: documents can be marked as legacy records;
aircraft have an "electronic records since" date (status report, package)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d719f663bc
commit
68a1719db2
53 files changed
+750
-12
No files matched your search
@@ -0,0 +1,52 @@
|
||||
# Electronic recordkeeping (AC 120-78B chapter 3):
|
||||
# - record_versions: every change to a maintenance record, chained by hash per
|
||||
# aircraft so removing or altering history shows (3.2.2, 3.2.4)
|
||||
# - integrity_checks: results of verifying those chains and the signatures
|
||||
# - backup_runs: the built-in database backups and their verification (3.2.7)
|
||||
# - app_revisions: which software versions ran when (3.2.6)
|
||||
# - legacy (paper) records: documents marked as such and the date the
|
||||
# electronic records start (3.2.8.10)
|
||||
class AddRecordsIntegrity < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
create_table :record_versions do |t|
|
||||
t.integer :aircraft_id, index: true
|
||||
t.string :item_type, null: false
|
||||
t.integer :item_id, null: false
|
||||
t.string :event, null: false
|
||||
t.integer :user_id
|
||||
t.string :ip_address
|
||||
t.text :payload, null: false
|
||||
t.string :prev_hash
|
||||
t.string :chain_hash, null: false
|
||||
t.datetime :created_at, null: false
|
||||
end
|
||||
add_index :record_versions, %i[item_type item_id]
|
||||
|
||||
create_table :integrity_checks do |t|
|
||||
t.boolean :ok, null: false
|
||||
t.integer :versions_checked, null: false, default: 0
|
||||
t.integer :signatures_checked, null: false, default: 0
|
||||
t.json :problems
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
create_table :backup_runs do |t|
|
||||
t.boolean :ok, null: false
|
||||
t.string :path
|
||||
t.bigint :bytes
|
||||
t.text :message
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
create_table :app_revisions do |t|
|
||||
t.string :revision, null: false
|
||||
t.datetime :built_at
|
||||
t.datetime :first_seen_at, null: false
|
||||
t.datetime :last_seen_at, null: false
|
||||
end
|
||||
add_index :app_revisions, :revision, unique: true
|
||||
|
||||
add_column :documents, :legacy_record, :boolean, null: false, default: false
|
||||
add_column :aircraft, :electronic_records_since, :date
|
||||
end
|
||||
end
|
||||
Generated
+44
-1
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.1].define(version: 2026_11_08_010000) do
|
||||
ActiveRecord::Schema[8.1].define(version: 2026_11_08_020000) do
|
||||
create_table "active_storage_attachments", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.string "record_type", null: false
|
||||
@@ -147,6 +147,7 @@ ActiveRecord::Schema[8.1].define(version: 2026_11_08_010000) do
|
||||
t.json "cg_envelope"
|
||||
t.string "ad_watch_terms"
|
||||
t.datetime "ad_watch_checked_at"
|
||||
t.date "electronic_records_since"
|
||||
end
|
||||
|
||||
create_table "aircraft_airworthiness_directives", id: false, force: :cascade do |t|
|
||||
@@ -285,6 +286,23 @@ ActiveRecord::Schema[8.1].define(version: 2026_11_08_010000) do
|
||||
t.index ["component_id", "airworthiness_directive_id"], name: "idx_component_ads", unique: true
|
||||
end
|
||||
|
||||
create_table "app_revisions", force: :cascade do |t|
|
||||
t.string "revision", null: false
|
||||
t.datetime "built_at"
|
||||
t.datetime "first_seen_at", null: false
|
||||
t.datetime "last_seen_at", null: false
|
||||
t.index ["revision"], name: "index_app_revisions_on_revision", unique: true
|
||||
end
|
||||
|
||||
create_table "backup_runs", force: :cascade do |t|
|
||||
t.boolean "ok", null: false
|
||||
t.string "path"
|
||||
t.bigint "bytes"
|
||||
t.text "message"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "component_types", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.boolean "consumable", default: false, null: false
|
||||
@@ -371,6 +389,7 @@ ActiveRecord::Schema[8.1].define(version: 2026_11_08_010000) do
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.date "expires_on"
|
||||
t.boolean "legacy_record", default: false, null: false
|
||||
t.index ["aircraft_id"], name: "index_documents_on_aircraft_id"
|
||||
t.index ["document_collection_id"], name: "index_documents_on_document_collection_id"
|
||||
end
|
||||
@@ -455,6 +474,15 @@ ActiveRecord::Schema[8.1].define(version: 2026_11_08_010000) do
|
||||
t.index ["satisfies_id"], name: "index_inspection_types_on_satisfies_id"
|
||||
end
|
||||
|
||||
create_table "integrity_checks", force: :cascade do |t|
|
||||
t.boolean "ok", null: false
|
||||
t.integer "versions_checked", default: 0, null: false
|
||||
t.integer "signatures_checked", default: 0, null: false
|
||||
t.json "problems"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "logbook_entries", force: :cascade do |t|
|
||||
t.integer "aircraft_id", null: false
|
||||
t.integer "document_id"
|
||||
@@ -584,6 +612,21 @@ ActiveRecord::Schema[8.1].define(version: 2026_11_08_010000) do
|
||||
t.index ["component_id"], name: "index_oil_analyses_on_component_id"
|
||||
end
|
||||
|
||||
create_table "record_versions", force: :cascade do |t|
|
||||
t.integer "aircraft_id"
|
||||
t.string "item_type", null: false
|
||||
t.integer "item_id", null: false
|
||||
t.string "event", null: false
|
||||
t.integer "user_id"
|
||||
t.string "ip_address"
|
||||
t.text "payload", null: false
|
||||
t.string "prev_hash"
|
||||
t.string "chain_hash", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.index ["aircraft_id"], name: "index_record_versions_on_aircraft_id"
|
||||
t.index ["item_type", "item_id"], name: "index_record_versions_on_item_type_and_item_id"
|
||||
end
|
||||
|
||||
create_table "sessions", force: :cascade do |t|
|
||||
t.integer "user_id", null: false
|
||||
t.string "ip_address"
|
||||
|
||||
Reference in new issue
Block a user