Merge pull request #1918 from tchak/procedure-en-test-migration
Procedure en test migration
This commit is contained in:
commit
2a18061ee0
4 changed files with 16 additions and 1 deletions
|
@ -153,7 +153,8 @@ class Procedure < ApplicationRecord
|
|||
end
|
||||
|
||||
def publish!(path)
|
||||
self.update!({ published_at: Time.now, archived_at: nil })
|
||||
now = Time.now
|
||||
self.update!({ test_started_at: now, published_at: now, archived_at: nil })
|
||||
ProcedurePath.create!(path: path, procedure: self, administrateur: self.administrateur)
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddTestStartedAtToProcedures < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :procedures, :test_started_at, :datetime, index: true
|
||||
end
|
||||
end
|
|
@ -464,6 +464,7 @@ ActiveRecord::Schema.define(version: 2018_05_02_092852) do
|
|||
t.string "web_hook_url"
|
||||
t.boolean "cloned_from_library", default: false
|
||||
t.bigint "parent_procedure_id"
|
||||
t.datetime "test_started_at"
|
||||
t.index ["hidden_at"], name: "index_procedures_on_hidden_at"
|
||||
t.index ["parent_procedure_id"], name: "index_procedures_on_parent_procedure_id"
|
||||
end
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
namespace :'2018_05_09_add_test_started_at_to_procedure' do
|
||||
task set: :environment do
|
||||
Procedure.publiees_ou_archivees.where(test_started_at: nil).find_each do |procedure|
|
||||
procedure.test_started_at = procedure.published_at
|
||||
procedure.save
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue