mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
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>
53 lines
1.8 KiB
Ruby
53 lines
1.8 KiB
Ruby
# 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
|