Project initialize
This commit is contained in:
10
db/migrate/20260120093711_create_tasks.rb
Normal file
10
db/migrate/20260120093711_create_tasks.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class CreateTasks < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :tasks do |t|
|
||||
t.string :title
|
||||
t.boolean :completed
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
5
db/migrate/20260120101432_add_description_to_tasks.rb
Normal file
5
db/migrate/20260120101432_add_description_to_tasks.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddDescriptionToTasks < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_column :tasks, :description, :text
|
||||
end
|
||||
end
|
||||
11
db/migrate/20260121074647_create_departments.rb
Normal file
11
db/migrate/20260121074647_create_departments.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class CreateDepartments < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :departments do |t|
|
||||
t.string :name, null: false
|
||||
t.text :description
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :departments, :name, unique: true
|
||||
end
|
||||
end
|
||||
14
db/migrate/20260121074803_create_users.rb
Normal file
14
db/migrate/20260121074803_create_users.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
class CreateUsers < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :users do |t|
|
||||
t.string :name, null: false
|
||||
t.string :email, null: false
|
||||
t.string :role, null: false, default: 'employee'
|
||||
t.references :department, foreign_key: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
add_index :users, :email, unique: true
|
||||
add_index :users, :role
|
||||
end
|
||||
end
|
||||
39
db/migrate/20260121075301_add_devise_to_users.rb
Normal file
39
db/migrate/20260121075301_add_devise_to_users.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddDeviseToUsers < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
change_table :users do |t|
|
||||
## Database authenticatable
|
||||
t.string :encrypted_password, null: false, default: ""
|
||||
|
||||
## Recoverable
|
||||
t.string :reset_password_token
|
||||
t.datetime :reset_password_sent_at
|
||||
|
||||
## Rememberable
|
||||
t.datetime :remember_created_at
|
||||
|
||||
## Trackable
|
||||
t.integer :sign_in_count, default: 0, null: false
|
||||
t.datetime :current_sign_in_at
|
||||
t.datetime :last_sign_in_at
|
||||
t.string :current_sign_in_ip
|
||||
t.string :last_sign_in_ip
|
||||
|
||||
## Confirmable
|
||||
t.string :confirmation_token
|
||||
t.datetime :confirmed_at
|
||||
t.datetime :confirmation_sent_at
|
||||
t.string :unconfirmed_email # Only if using reconfirmable
|
||||
|
||||
## Lockable
|
||||
t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
|
||||
t.string :unlock_token # Only if unlock strategy is :email or : both
|
||||
t.datetime :locked_at
|
||||
end
|
||||
|
||||
add_index :users, :reset_password_token, unique: true
|
||||
add_index :users, :confirmation_token, unique: true
|
||||
add_index :users, :unlock_token, unique: true
|
||||
end
|
||||
end
|
||||
13
db/migrate/20260122034424_add_company_fields_to_tasks.rb
Normal file
13
db/migrate/20260122034424_add_company_fields_to_tasks.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class AddCompanyFieldsToTasks < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_column :tasks, :priority, :string, null: false, default: 'planning'
|
||||
add_column :tasks, :status, :string, null: false, default: 'open'
|
||||
add_reference :tasks, :department, foreign_key: true
|
||||
add_reference :tasks, :assignee, foreign_key: { to_table: :users }
|
||||
add_reference :tasks, :creator, foreign_key: { to_table: :users }
|
||||
|
||||
add_index :tasks, :priority
|
||||
add_index :tasks, :status
|
||||
add_index :tasks, [:department_id, :status]
|
||||
end
|
||||
end
|
||||
12
db/migrate/20260122043706_create_task_activities.rb
Normal file
12
db/migrate/20260122043706_create_task_activities.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreateTaskActivities < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :task_activities do |t|
|
||||
t.references :task, foreign_key: true
|
||||
t.references :user, foreign_key: true
|
||||
t.string :action
|
||||
t.text :details
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user