feat: CRUD operation for associated articles to current article (#4912)
This commit is contained in:
5
db/migrate/20220608084622_add_associated_article_id.rb
Normal file
5
db/migrate/20220608084622_add_associated_article_id.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddAssociatedArticleId < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_reference :articles, :associated_article, foreign_key: { to_table: :articles }
|
||||
end
|
||||
end
|
||||
12
db/migrate/20220628124837_create_portal_members.rb
Normal file
12
db/migrate/20220628124837_create_portal_members.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreatePortalMembers < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
create_table :portal_members do |t|
|
||||
t.bigint :portal_id
|
||||
t.bigint :user_id
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :portal_members, [:portal_id, :user_id], unique: true
|
||||
add_index :portal_members, [:user_id, :portal_id], unique: true
|
||||
end
|
||||
end
|
||||
14
db/schema.rb
14
db/schema.rb
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2022_06_27_135753) do
|
||||
ActiveRecord::Schema.define(version: 2022_06_28_124837) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_stat_statements"
|
||||
@@ -126,6 +126,8 @@ ActiveRecord::Schema.define(version: 2022_06_27_135753) do
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.bigint "author_id"
|
||||
t.bigint "associated_article_id"
|
||||
t.index ["associated_article_id"], name: "index_articles_on_associated_article_id"
|
||||
t.index ["author_id"], name: "index_articles_on_author_id"
|
||||
end
|
||||
|
||||
@@ -663,6 +665,15 @@ ActiveRecord::Schema.define(version: 2022_06_27_135753) do
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
end
|
||||
|
||||
create_table "portal_members", force: :cascade do |t|
|
||||
t.bigint "portal_id"
|
||||
t.bigint "user_id"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.index ["portal_id", "user_id"], name: "index_portal_members_on_portal_id_and_user_id", unique: true
|
||||
t.index ["user_id", "portal_id"], name: "index_portal_members_on_user_id_and_portal_id", unique: true
|
||||
end
|
||||
|
||||
create_table "portals", force: :cascade do |t|
|
||||
t.integer "account_id", null: false
|
||||
t.string "name", null: false
|
||||
@@ -836,6 +847,7 @@ ActiveRecord::Schema.define(version: 2022_06_27_135753) do
|
||||
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
||||
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
||||
add_foreign_key "agent_bots", "accounts", on_delete: :cascade
|
||||
add_foreign_key "articles", "articles", column: "associated_article_id"
|
||||
add_foreign_key "articles", "users", column: "author_id"
|
||||
add_foreign_key "campaigns", "accounts", on_delete: :cascade
|
||||
add_foreign_key "campaigns", "inboxes", on_delete: :cascade
|
||||
|
||||
Reference in New Issue
Block a user