2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/generators/todoro/templates/create_todoro_tasks.rb', line 2
def change
create_table :todoro_tasks do |t|
t.string :title
t.text :description, null: false t.datetime :expiry_date
t.string :status, null: false, default: "pending" t.references :task_list, null: false, foreign_key: { to_table: :todoro_task_lists }
t.timestamps
end
execute <<-SQL
ALTER TABLE todoro_tasks
ADD CONSTRAINT status_check
CHECK (status IN ('pending', 'completed'));
SQL
end
|