add Axis, Category and Subject
This commit is contained in:
11
db/migrate/20220721123241_create_categories.rb
Normal file
11
db/migrate/20220721123241_create_categories.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class CreateCategories < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
create_table :categories do |t|
|
||||
t.string :name
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index(:categories, :name, unique: true)
|
||||
end
|
||||
end
|
||||
11
db/migrate/20220721123254_create_axes.rb
Normal file
11
db/migrate/20220721123254_create_axes.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class CreateAxes < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
create_table :axes do |t|
|
||||
t.string :name
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index(:axes, :name, unique: true)
|
||||
end
|
||||
end
|
||||
13
db/migrate/20220721123327_create_subjects.rb
Normal file
13
db/migrate/20220721123327_create_subjects.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class CreateSubjects < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
create_table :subjects do |t|
|
||||
t.string :name
|
||||
t.references :category, null: false, foreign_key: true
|
||||
t.references :axis, null: false, foreign_key: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index(:subjects, :name, unique: true)
|
||||
end
|
||||
end
|
||||
29
db/schema.rb
generated
29
db/schema.rb
generated
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.0].define(version: 2022_07_21_015136) do
|
||||
ActiveRecord::Schema[7.0].define(version: 2022_07_21_123327) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
@@ -28,6 +28,31 @@ ActiveRecord::Schema[7.0].define(version: 2022_07_21_015136) do
|
||||
t.index ["resource_type", "resource_id"], name: "index_active_admin_comments_on_resource"
|
||||
end
|
||||
|
||||
create_table "axes", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["name"], name: "index_axes_on_name", unique: true
|
||||
end
|
||||
|
||||
create_table "categories", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["name"], name: "index_categories_on_name", unique: true
|
||||
end
|
||||
|
||||
create_table "subjects", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.bigint "category_id", null: false
|
||||
t.bigint "axis_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["axis_id"], name: "index_subjects_on_axis_id"
|
||||
t.index ["category_id"], name: "index_subjects_on_category_id"
|
||||
t.index ["name"], name: "index_subjects_on_name", unique: true
|
||||
end
|
||||
|
||||
create_table "users", force: :cascade do |t|
|
||||
t.string "email", default: "", null: false
|
||||
t.string "encrypted_password", default: "", null: false
|
||||
@@ -41,4 +66,6 @@ ActiveRecord::Schema[7.0].define(version: 2022_07_21_015136) do
|
||||
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
||||
end
|
||||
|
||||
add_foreign_key "subjects", "axes"
|
||||
add_foreign_key "subjects", "categories"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user