Skip to content

Commit f9166eb

Browse files
authored
feat(db): create systems table (#2754)
Setup UUID-based systems table with org_id, tags, system_profile, and unique insights_id to host data locally. https://redhat.atlassian.net/browse/RHINENG-23278 ## Secure Coding Practices Checklist GitHub Link - https://github.com/RedHatInsights/secure-coding-checklist ## Secure Coding Checklist - [ ] Input Validation - [ ] Output Encoding - [ ] Authentication and Password Management - [ ] Session Management - [ ] Access Control - [ ] Cryptographic Practices - [ ] Error Handling and Logging - [ ] Data Protection - [ ] Communication Security - [ ] System Configuration - [ ] Database Security - [ ] File Management - [ ] Memory Management - [x] General Coding Practices
2 parents a45b493 + dc33671 commit f9166eb

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class CreateSystems < ActiveRecord::Migration[7.1]
2+
def change
3+
create_table :systems, id: :uuid do |t|
4+
t.string :account, limit: 10
5+
t.string :org_id, limit: 10, null: false
6+
t.string :display_name, limit: 200, null: false
7+
t.jsonb :tags, null: false, default: {}
8+
t.datetime :updated, null: false
9+
t.datetime :created, null: false
10+
t.datetime :stale_timestamp, null: false
11+
t.jsonb :system_profile, null: false, default: {}
12+
t.jsonb :groups, default: []
13+
t.uuid :insights_id
14+
t.datetime :deleted_at
15+
end
16+
17+
add_index :systems, :insights_id, unique: true
18+
end
19+
end

db/schema.rb

Lines changed: 16 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[8.1].define(version: 2026_05_28_153533) do
13+
ActiveRecord::Schema[8.1].define(version: 2026_06_08_090600) do
1414
# These are extensions that must be enabled in order to support this database
1515
enable_extension "dblink"
1616
enable_extension "pgcrypto"
@@ -281,6 +281,21 @@
281281
t.index ["ref_id", "version"], name: "index_security_guides_v2_on_ref_id_and_version", unique: true
282282
end
283283

284+
create_table "systems", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
285+
t.string "account", limit: 10
286+
t.datetime "created", null: false
287+
t.datetime "deleted_at"
288+
t.string "display_name", limit: 200, null: false
289+
t.jsonb "groups", default: []
290+
t.uuid "insights_id"
291+
t.string "org_id", limit: 10, null: false
292+
t.datetime "stale_timestamp", null: false
293+
t.jsonb "system_profile", default: {}, null: false
294+
t.jsonb "tags", default: {}, null: false
295+
t.datetime "updated", null: false
296+
t.index ["insights_id"], name: "index_systems_on_insights_id", unique: true
297+
end
298+
284299
create_table "tailoring_rules_v2", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
285300
t.datetime "created_at", precision: nil
286301
t.uuid "rule_id", null: false

0 commit comments

Comments
 (0)