mirror of
https://github.com/System-End/hackatime.git
synced 2026-04-19 19:55:16 +00:00
* Drop unused heartbeat lookup tables and their FK columns Remove 8 abandoned normalization tables (heartbeat_branches, heartbeat_categories, heartbeat_editors, heartbeat_languages, heartbeat_machines, heartbeat_operating_systems, heartbeat_projects, heartbeat_user_agents) and their corresponding foreign key columns from the heartbeats table. None had models, associations, or any application code referencing them. * Remove migrations cancelling each other out
24 lines
1.2 KiB
Ruby
24 lines
1.2 KiB
Ruby
class CreateRepoHostEvents < ActiveRecord::Migration[8.1]
|
|
def change
|
|
# id: false because we are defining a custom string primary key 'id'
|
|
create_table :repo_host_events, id: false do |t|
|
|
t.string :id, null: false, primary_key: true # Custom PK: e.g., gh_eventid123
|
|
t.references :user, null: false, foreign_key: true
|
|
t.jsonb :raw_event_payload, null: false # Stores the actual event content from GitHub
|
|
t.integer :provider, null: false, default: 0 # 0 for GitHub
|
|
|
|
# Per prompt: "created_at is created_at from gh json"
|
|
# This means the AR `created_at` field will store the event's timestamp from GitHub.
|
|
# Rails' `updated_at` will track when our DB record was last modified.
|
|
t.datetime :created_at, null: false
|
|
t.datetime :updated_at, null: false
|
|
end
|
|
|
|
# Add an index on provider for filtering
|
|
add_index :repo_host_events, :provider
|
|
# Add an index for efficiently finding the latest event for a user/provider,
|
|
# and for the "stop fetching if event exists" logic.
|
|
# The primary key `id` is already unique and indexed.
|
|
add_index :repo_host_events, [ :user_id, :provider, :created_at ], name: 'index_repo_host_events_on_user_provider_created_at'
|
|
end
|
|
end
|