Project and Task models
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
class Project < ApplicationRecord
|
||||
validates :name, :code, presence: true
|
||||
|
||||
has_many :tasks
|
||||
|
||||
has_rich_text :description
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
class Task < ApplicationRecord
|
||||
belongs_to :project
|
||||
|
||||
validates :number, :title, presence: true
|
||||
validates :number, numericality: { greater_than: 0 }
|
||||
|
||||
has_rich_text :description
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
class CreateProjects < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :projects do |t|
|
||||
t.string :name, null: false
|
||||
t.string :code, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :projects, :name
|
||||
add_index :projects, :code, unique: true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class CreateTasks < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :tasks do |t|
|
||||
t.references :project, null: false, foreign_key: true
|
||||
t.integer :number, null: false
|
||||
t.string :title, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
Generated
+20
-1
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_06_21_202543) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_06_21_203940) do
|
||||
create_table "action_text_rich_texts", charset: "utf8mb4", collation: "utf8mb4_uca1400_ai_ci", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.text "body", size: :long
|
||||
@@ -49,6 +49,15 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_21_202543) do
|
||||
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
|
||||
end
|
||||
|
||||
create_table "projects", charset: "utf8mb4", collation: "utf8mb4_uca1400_ai_ci", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.string "code", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["code"], name: "index_projects_on_code", unique: true
|
||||
t.index ["name"], name: "index_projects_on_name"
|
||||
end
|
||||
|
||||
create_table "sessions", charset: "utf8mb4", collation: "utf8mb4_uca1400_ai_ci", force: :cascade do |t|
|
||||
t.bigint "user_id", null: false
|
||||
t.string "ip_address"
|
||||
@@ -58,6 +67,15 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_21_202543) do
|
||||
t.index ["user_id"], name: "index_sessions_on_user_id"
|
||||
end
|
||||
|
||||
create_table "tasks", charset: "utf8mb4", collation: "utf8mb4_uca1400_ai_ci", force: :cascade do |t|
|
||||
t.bigint "project_id", null: false
|
||||
t.integer "number", null: false
|
||||
t.string "title", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["project_id"], name: "index_tasks_on_project_id"
|
||||
end
|
||||
|
||||
create_table "users", charset: "utf8mb4", collation: "utf8mb4_uca1400_ai_ci", force: :cascade do |t|
|
||||
t.string "email_address", null: false
|
||||
t.string "password_digest", null: false
|
||||
@@ -69,4 +87,5 @@ ActiveRecord::Schema[8.0].define(version: 2025_06_21_202543) 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 "sessions", "users"
|
||||
add_foreign_key "tasks", "projects"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user