Skip to content

Commit 430b651

Browse files
committed
feat: add creator association to pages and update schema
1 parent 1f76564 commit 430b651

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

app/models/better_together/page.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class Page < ApplicationRecord
3838
}, through: :page_blocks, source: :block
3939

4040
belongs_to :sidebar_nav, class_name: 'BetterTogether::NavigationArea', optional: true
41+
belongs_to :creator, class_name: 'BetterTogether::Person', optional: true
4142

4243
accepts_nested_attributes_for :page_blocks, allow_destroy: true
4344

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# frozen_string_literal: true
2+
3+
# Adds creator_id to pages table
4+
class AddCreatorToPages < ActiveRecord::Migration[8.0]
5+
def change
6+
add_column :better_together_pages, :creator_id, :uuid
7+
add_index :better_together_pages, :creator_id
8+
add_foreign_key :better_together_pages, :better_together_people, column: :creator_id
9+
end
10+
end

spec/dummy/db/schema.rb

Lines changed: 4 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[7.2].define(version: 2025_11_20_160356) do
13+
ActiveRecord::Schema[7.2].define(version: 2025_11_25_142646) do
1414
# These are extensions that must be enabled in order to support this database
1515
enable_extension "pg_catalog.plpgsql"
1616
enable_extension "pgcrypto"
@@ -1007,6 +1007,8 @@
10071007
t.string "layout"
10081008
t.string "template"
10091009
t.uuid "sidebar_nav_id"
1010+
t.uuid "creator_id"
1011+
t.index ["creator_id"], name: "index_better_together_pages_on_creator_id"
10101012
t.index ["identifier"], name: "index_better_together_pages_on_identifier", unique: true
10111013
t.index ["privacy"], name: "by_page_privacy"
10121014
t.index ["published_at"], name: "by_page_publication_date"
@@ -1535,6 +1537,7 @@
15351537
add_foreign_key "better_together_navigation_items", "better_together_navigation_areas", column: "navigation_area_id"
15361538
add_foreign_key "better_together_navigation_items", "better_together_navigation_items", column: "parent_id"
15371539
add_foreign_key "better_together_pages", "better_together_navigation_areas", column: "sidebar_nav_id"
1540+
add_foreign_key "better_together_pages", "better_together_people", column: "creator_id"
15381541
add_foreign_key "better_together_people", "better_together_communities", column: "community_id"
15391542
add_foreign_key "better_together_person_blocks", "better_together_people", column: "blocked_id"
15401543
add_foreign_key "better_together_person_blocks", "better_together_people", column: "blocker_id"

0 commit comments

Comments
 (0)