Skip to content

Commit 955f903

Browse files
committed
MIGRATION: Add index on application_events created_at
1 parent e47ab39 commit 955f903

File tree

7 files changed

+60
-1
lines changed

7 files changed

+60
-1
lines changed

app/models/application_event.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
# created_at :datetime not null
1010
# updated_at :datetime not null
1111
#
12+
# Indexes
13+
#
14+
# index_application_events_on_created_at (created_at)
15+
#
1216
class ApplicationEvent < ApplicationRecord
1317
serialize :data, coder: JSON
1418
serialize :metadata, coder: JSON

app/models/application_events/deploy.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# == Schema Information
2+
#
3+
# Table name: application_events
4+
#
5+
# id :string not null, primary key
6+
# data :text not null
7+
# metadata :text
8+
# type :string not null
9+
# created_at :datetime not null
10+
# updated_at :datetime not null
11+
#
12+
# Indexes
13+
#
14+
# index_application_events_on_created_at (created_at)
15+
#
116
module ApplicationEvents
217
class Deploy < ::ApplicationEvent
318
DATA_SCHEMA = {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class IndexApplicationEventsCreatedAt < ActiveRecord::Migration[8.1]
2+
def change
3+
add_index :application_events, :created_at
4+
end
5+
end

db/schema.rb

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/factories/application_events.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# == Schema Information
2+
#
3+
# Table name: application_events
4+
#
5+
# id :string not null, primary key
6+
# data :text not null
7+
# metadata :text
8+
# type :string not null
9+
# created_at :datetime not null
10+
# updated_at :datetime not null
11+
#
12+
# Indexes
13+
#
14+
# index_application_events_on_created_at (created_at)
15+
#
116
FactoryBot.define do
217
factory :application_event do
318
data { {key: "value"}.to_json }

spec/models/application_event_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
# created_at :datetime not null
1010
# updated_at :datetime not null
1111
#
12+
# Indexes
13+
#
14+
# index_application_events_on_created_at (created_at)
15+
#
1216
require "rails_helper"
1317

1418
RSpec.describe ApplicationEvent, type: :model do

spec/models/application_events/deploy_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# == Schema Information
2+
#
3+
# Table name: application_events
4+
#
5+
# id :string not null, primary key
6+
# data :text not null
7+
# metadata :text
8+
# type :string not null
9+
# created_at :datetime not null
10+
# updated_at :datetime not null
11+
#
12+
# Indexes
13+
#
14+
# index_application_events_on_created_at (created_at)
15+
#
116
require "rails_helper"
217

318
RSpec.describe ApplicationEvents::Deploy do

0 commit comments

Comments
 (0)