2020-08-07 01:14:14 +02:00
|
|
|
class CreateTasks < ActiveRecord::Migration[4.2]
|
2009-01-06 11:49:19 +01:00
|
|
|
def self.up
|
|
|
|
create_table :tasks do |t|
|
2023-05-12 13:01:12 +02:00
|
|
|
t.column :name, :string, null: false
|
2009-01-06 11:49:19 +01:00
|
|
|
t.column :description, :string
|
|
|
|
t.column :due_date, :date
|
2023-05-12 13:01:12 +02:00
|
|
|
t.column :done, :boolean, default: false
|
2009-01-06 11:49:19 +01:00
|
|
|
t.column :group_id, :integer
|
2023-05-12 13:01:12 +02:00
|
|
|
t.column :assigned, :boolean, default: false
|
|
|
|
t.column :created_on, :datetime, null: false
|
|
|
|
t.column :updated_on, :datetime, null: false
|
2009-01-06 11:49:19 +01:00
|
|
|
end
|
|
|
|
add_index :tasks, :name
|
|
|
|
add_index :tasks, :due_date
|
2021-03-01 15:27:26 +01:00
|
|
|
|
2009-01-06 11:49:19 +01:00
|
|
|
create_table :assignments do |t|
|
2023-05-12 13:01:12 +02:00
|
|
|
t.column :user_id, :integer, null: false
|
|
|
|
t.column :task_id, :integer, null: false
|
|
|
|
t.column :accepted, :boolean, default: false
|
2009-01-06 11:49:19 +01:00
|
|
|
end
|
2023-05-12 13:01:12 +02:00
|
|
|
add_index :assignments, %i[user_id task_id], unique: true
|
2021-03-01 15:27:26 +01:00
|
|
|
|
2023-05-12 13:01:12 +02:00
|
|
|
add_column :groups, :weekly_task, :boolean, default: false # if group has an job for every week
|
2009-01-06 11:49:19 +01:00
|
|
|
add_column :groups, :weekday, :integer # e.g. 1 means monday, 2 = tuesday an so on
|
|
|
|
add_column :groups, :task_name, :string # the name of the weekly task
|
|
|
|
add_column :groups, :task_description, :string
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.down
|
|
|
|
drop_table :tasks
|
|
|
|
drop_table :assignments
|
|
|
|
remove_column :groups, :weekly_task
|
|
|
|
remove_column :groups, :weekday
|
|
|
|
remove_column :groups, :task_name
|
|
|
|
remove_column :groups, :task_description
|
|
|
|
end
|
|
|
|
end
|