Skip to content

Commit 49c859d

Browse files
committed
MIGRATION: Add more Page timestamps
1 parent 9e2c706 commit 49c859d

File tree

10 files changed

+109
-1
lines changed

10 files changed

+109
-1
lines changed

app/models/page.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
# Table name: pages
77
#
88
# id :string not null, primary key
9+
# indexed_at :datetime
10+
# published_at :datetime
911
# request_path :string not null
1012
# created_at :datetime not null
1113
# updated_at :datetime not null
1214
#
1315
# Indexes
1416
#
17+
# index_pages_on_indexed_at (indexed_at)
18+
# index_pages_on_published_at (published_at)
1519
# index_pages_on_request_path (request_path) UNIQUE
1620
#
1721
class Page < ApplicationRecord

app/models/page_topic.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
# == Schema Information
2+
#
3+
# Table name: page_topics
4+
#
5+
# id :integer not null, primary key
6+
# created_at :datetime not null
7+
# updated_at :datetime not null
8+
# page_id :string not null
9+
# topic_id :integer not null
10+
#
11+
# Indexes
12+
#
13+
# index_page_topics_on_page_id (page_id)
14+
# index_page_topics_on_page_id_and_topic_id (page_id,topic_id) UNIQUE
15+
# index_page_topics_on_topic_id (topic_id)
16+
#
17+
# Foreign Keys
18+
#
19+
# page_id (page_id => pages.id)
20+
# topic_id (topic_id => topics.id)
21+
#
122
class PageTopic < ApplicationRecord
223
belongs_to :page
324
belongs_to :topic, counter_cache: :pages_count

app/models/topic.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
# == Schema Information
2+
#
3+
# Table name: topics
4+
#
5+
# id :integer not null, primary key
6+
# description :text
7+
# name :string
8+
# pages_count :integer default(0), not null
9+
# slug :string not null
10+
# status :string default("pending"), not null
11+
# created_at :datetime not null
12+
# updated_at :datetime not null
13+
#
14+
# Indexes
15+
#
16+
# index_topics_on_pages_count (pages_count)
17+
# index_topics_on_slug (slug) UNIQUE
18+
# index_topics_on_status (status)
19+
#
120
class Topic < ApplicationRecord
221
include Sluggable
322

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class AddPublishedAtToPages < ActiveRecord::Migration[8.0]
2+
def change
3+
add_column :pages, :published_at, :datetime, null: true
4+
5+
add_index :pages, :published_at
6+
end
7+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class AddIndexedAtToPages < ActiveRecord::Migration[8.0]
2+
def change
3+
add_column :pages, :indexed_at, :datetime, null: true
4+
5+
add_index :pages, :indexed_at
6+
end
7+
end

db/schema.rb

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

spec/factories/pages.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
# Table name: pages
44
#
55
# id :string not null, primary key
6+
# indexed_at :datetime
7+
# published_at :datetime
68
# request_path :string not null
79
# created_at :datetime not null
810
# updated_at :datetime not null
911
#
1012
# Indexes
1113
#
14+
# index_pages_on_indexed_at (indexed_at)
15+
# index_pages_on_published_at (published_at)
1216
# index_pages_on_request_path (request_path) UNIQUE
1317
#
1418
FactoryBot.define do

spec/factories/topics.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
# spec/factories/topics.rb
2+
# == Schema Information
3+
#
4+
# Table name: topics
5+
#
6+
# id :integer not null, primary key
7+
# description :text
8+
# name :string
9+
# pages_count :integer default(0), not null
10+
# slug :string not null
11+
# status :string default("pending"), not null
12+
# created_at :datetime not null
13+
# updated_at :datetime not null
14+
#
15+
# Indexes
16+
#
17+
# index_topics_on_pages_count (pages_count)
18+
# index_topics_on_slug (slug) UNIQUE
19+
# index_topics_on_status (status)
20+
#
221
FactoryBot.define do
322
factory :topic do
423
sequence(:name) { |n| "Topic #{n}" }

spec/models/page_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
# Table name: pages
44
#
55
# id :string not null, primary key
6+
# indexed_at :datetime
7+
# published_at :datetime
68
# request_path :string not null
79
# created_at :datetime not null
810
# updated_at :datetime not null
911
#
1012
# Indexes
1113
#
14+
# index_pages_on_indexed_at (indexed_at)
15+
# index_pages_on_published_at (published_at)
1216
# index_pages_on_request_path (request_path) UNIQUE
1317
#
1418
require "rails_helper"

spec/models/topic_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
# == Schema Information
2+
#
3+
# Table name: topics
4+
#
5+
# id :integer not null, primary key
6+
# description :text
7+
# name :string
8+
# pages_count :integer default(0), not null
9+
# slug :string not null
10+
# status :string default("pending"), not null
11+
# created_at :datetime not null
12+
# updated_at :datetime not null
13+
#
14+
# Indexes
15+
#
16+
# index_topics_on_pages_count (pages_count)
17+
# index_topics_on_slug (slug) UNIQUE
18+
# index_topics_on_status (status)
19+
#
120
require "rails_helper"
221

322
RSpec.describe Topic, type: :model do

0 commit comments

Comments
 (0)