diff --git a/db/migrate/20250808184750_create_project_labels.rb b/db/migrate/20250808184750_create_project_labels.rb new file mode 100644 index 00000000..3fb2f41e --- /dev/null +++ b/db/migrate/20250808184750_create_project_labels.rb @@ -0,0 +1,15 @@ +class CreateProjectLabels < ActiveRecord::Migration[8.0] + # where was ts before? + # precedent for future to make migration infallible + def change + create_table :project_labels, if_not_exists: true do |t| + t.string :user_id, null: false + t.string :project_key, null: false + t.string :label, null: false + t.timestamps + end + + add_index :project_labels, [ :user_id, :project_key ], unique: true, if_not_exists: true + add_index :project_labels, :user_id, if_not_exists: true + end +end diff --git a/db/schema.rb b/db/schema.rb index 4eef9b15..3548e8de 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2025_07_09_001202) do +ActiveRecord::Schema[8.0].define(version: 2025_08_08_184750) do create_schema "pganalyze" # These are extensions that must be enabled in order to support this database @@ -258,6 +258,8 @@ t.bigint "raw_heartbeat_upload_id" t.index ["category", "time"], name: "index_heartbeats_on_category_and_time" t.index ["fields_hash"], name: "index_heartbeats_on_fields_hash_when_not_deleted", unique: true, where: "(deleted_at IS NULL)" + t.index ["project", "time"], name: "index_heartbeats_on_project_and_time" + t.index ["project"], name: "index_heartbeats_on_project" t.index ["raw_heartbeat_upload_id"], name: "index_heartbeats_on_raw_heartbeat_upload_id" t.index ["source_type", "time", "user_id", "project"], name: "index_heartbeats_on_source_type_time_user_project" t.index ["user_id", "project", "time"], name: "idx_heartbeats_user_project_time_stats", where: "((deleted_at IS NULL) AND (project IS NOT NULL))" @@ -392,6 +394,16 @@ t.index ["user_id"], name: "index_physical_mails_on_user_id" end + create_table "project_labels", force: :cascade do |t| + t.string "project_key", null: false + t.string "label", null: false + t.string "user_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["user_id", "project_key"], name: "index_project_labels_on_user_id_and_project_key", unique: true + t.index ["user_id"], name: "index_project_labels_on_user_id" + end + create_table "project_repo_mappings", force: :cascade do |t| t.bigint "user_id", null: false t.string "project_name", null: false diff --git a/db/seeds.rb b/db/seeds.rb index eda300e9..3dcbba27 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -7,7 +7,7 @@ # Creating test user test_user = User.find_or_create_by(slack_uid: 'TEST123456') do |user| user.username = 'testuser' - user.is_admin = true + user.admin_level = 2 # Ensure timezone is set to avoid nil timezone issues user.timezone = 'America/New_York' end