8f73e1e1be
To keep as much of this as we can in the `fizzy-saas` gem, this PR opts to store console/audits models in a separate database, and so: - the gem contains the migrations and the database config - the app contains a separate schema file distinctly for SaaS concerns - Rails' current behavior prevents us from easily keeping this file in the gem Also note that the stock `audits1984` schema is updated to reference the auditor via a UUID foreign key. Finally, in order for the database schema file to be located in the gem directory (and not the application directory), it's necessary to monkeypatch `AR::DatabaseTasks.schema_dump_path` to support absolute paths. This functionality has been proposed upstream in https://github.com/rails/rails/pull/56290 but is awaiting a decision from the core team. ref: https://app.fizzy.do/5986089/cards/2469 ref: #17
37 lines
962 B
Ruby
37 lines
962 B
Ruby
# This migration comes from console1984 (originally 20210517203931)
|
|
class CreateConsole1984Tables < ActiveRecord::Migration[7.0]
|
|
def change
|
|
create_table :console1984_sessions do |t|
|
|
t.text :reason
|
|
t.references :user, null: false, index: false
|
|
t.timestamps
|
|
|
|
t.index :created_at
|
|
t.index [ :user_id, :created_at ]
|
|
end
|
|
|
|
create_table :console1984_users do |t|
|
|
t.string :username, null: false
|
|
t.timestamps
|
|
|
|
t.index [:username]
|
|
end
|
|
|
|
create_table :console1984_commands do |t|
|
|
t.text :statements
|
|
t.references :sensitive_access
|
|
t.references :session, null: false, index: false
|
|
t.timestamps
|
|
|
|
t.index [ :session_id, :created_at, :sensitive_access_id ], name: "on_session_and_sensitive_chronologically"
|
|
end
|
|
|
|
create_table :console1984_sensitive_accesses do |t|
|
|
t.text :justification
|
|
t.references :session, null: false
|
|
|
|
t.timestamps
|
|
end
|
|
end
|
|
end
|