Skip to content
Snippets Groups Projects
Unverified Commit a99d8b2e authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

wip menu models

parent bf636d9f
No related branches found
No related tags found
No related merge requests found
# == Schema Information
#
# Table name: communication_website_menus
#
# id :uuid not null, primary key
# identifier :string
# title :string
# created_at :datetime not null
# updated_at :datetime not null
# university_id :uuid not null
# website_id :uuid not null
#
# Indexes
#
# index_communication_website_menus_on_university_id (university_id)
# index_communication_website_menus_on_website_id (website_id)
#
# Foreign Keys
#
# fk_rails_... (university_id => universities.id)
# fk_rails_... (website_id => communication_websites.id)
#
class Communication::Website::Menu < ApplicationRecord
belongs_to :university
belongs_to :website, class_name: 'Communication::Website'
end
# == Schema Information
#
# Table name: communication_website_menu_items
#
# id :uuid not null, primary key
# about_type :string
# kind :integer default("url")
# position :integer
# title :string
# created_at :datetime not null
# updated_at :datetime not null
# about_id :uuid
# menu_id :uuid not null
# parent_id :uuid
# university_id :uuid not null
# website_id :uuid not null
#
# Indexes
#
# index_communication_website_menu_items_on_about (about_type,about_id)
# index_communication_website_menu_items_on_menu_id (menu_id)
# index_communication_website_menu_items_on_parent_id (parent_id)
# index_communication_website_menu_items_on_university_id (university_id)
# index_communication_website_menu_items_on_website_id (website_id)
#
# Foreign Keys
#
# fk_rails_... (menu_id => communication_website_menus.id)
# fk_rails_... (parent_id => communication_website_menu_items.id)
# fk_rails_... (university_id => universities.id)
# fk_rails_... (website_id => communication_websites.id)
#
class Communication::Website::Menu::Item < ApplicationRecord
belongs_to :university
belongs_to :website, class_name: 'Communication::Website'
belongs_to :menu, class_name: 'Communication::Website::Menu'
belongs_to :parent, class_name: 'Communication::Website::Menu::Item', optional: true
belongs_to :about, polymorphic: true, optional: true
enum kind: { url: 0, page: 1 }
end
class CreateCommunicationWebsiteMenus < ActiveRecord::Migration[6.1]
def change
create_table :communication_website_menus, id: :uuid do |t|
t.references :university, null: false, foreign_key: true, type: :uuid
t.references :website, null: false, foreign_key: { to_table: :communication_websites }, type: :uuid
t.string :title
t.string :identifier
t.timestamps
end
end
end
class CreateCommunicationWebsiteMenuItems < ActiveRecord::Migration[6.1]
def change
create_table :communication_website_menu_items, id: :uuid do |t|
t.references :university, null: false, foreign_key: true, type: :uuid
t.references :website, null: false, foreign_key: { to_table: :communication_websites }, type: :uuid
t.references :menu, null: false, foreign_key: { to_table: :communication_website_menus }, type: :uuid
t.string :title
t.integer :position
t.integer :kind, default: 0
t.references :parent, foreign_key: { to_table: :communication_website_menu_items }, type: :uuid
t.references :about, polymorphic: true, type: :uuid
t.timestamps
end
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_11_02_160400) do
ActiveRecord::Schema.define(version: 2021_11_03_103742) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
......@@ -224,6 +224,36 @@ ActiveRecord::Schema.define(version: 2021_11_02_160400) do
t.index ["website_id"], name: "index_communication_website_imported_websites_on_website_id"
end
create_table "communication_website_menu_items", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "university_id", null: false
t.uuid "website_id", null: false
t.uuid "menu_id", null: false
t.string "title"
t.integer "position"
t.integer "kind", default: 0
t.uuid "parent_id"
t.string "about_type"
t.uuid "about_id"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["about_type", "about_id"], name: "index_communication_website_menu_items_on_about"
t.index ["menu_id"], name: "index_communication_website_menu_items_on_menu_id"
t.index ["parent_id"], name: "index_communication_website_menu_items_on_parent_id"
t.index ["university_id"], name: "index_communication_website_menu_items_on_university_id"
t.index ["website_id"], name: "index_communication_website_menu_items_on_website_id"
end
create_table "communication_website_menus", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "university_id", null: false
t.uuid "website_id", null: false
t.string "title"
t.string "identifier"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["university_id"], name: "index_communication_website_menus_on_university_id"
t.index ["website_id"], name: "index_communication_website_menus_on_website_id"
end
create_table "communication_website_pages", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "university_id", null: false
t.uuid "communication_website_id", null: false
......@@ -488,6 +518,12 @@ ActiveRecord::Schema.define(version: 2021_11_02_160400) do
add_foreign_key "communication_website_imported_posts", "universities"
add_foreign_key "communication_website_imported_websites", "communication_websites", column: "website_id"
add_foreign_key "communication_website_imported_websites", "universities"
add_foreign_key "communication_website_menu_items", "communication_website_menu_items", column: "parent_id"
add_foreign_key "communication_website_menu_items", "communication_website_menus", column: "menu_id"
add_foreign_key "communication_website_menu_items", "communication_websites", column: "website_id"
add_foreign_key "communication_website_menu_items", "universities"
add_foreign_key "communication_website_menus", "communication_websites", column: "website_id"
add_foreign_key "communication_website_menus", "universities"
add_foreign_key "communication_website_pages", "communication_website_pages", column: "parent_id"
add_foreign_key "communication_website_pages", "communication_websites"
add_foreign_key "communication_website_pages", "universities"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment