Merge pull request #1059 from sgmap/add-timestamps-to-entreprise
Add timestamps on Entreprises
This commit is contained in:
commit
9e1ca5258a
3 changed files with 29 additions and 2 deletions
|
@ -0,0 +1,6 @@
|
||||||
|
class AddTimestampsToEntreprise < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
add_column :entreprises, :created_at, :datetime
|
||||||
|
add_column :entreprises, :updated_at, :datetime
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20171123125346) do
|
ActiveRecord::Schema.define(version: 20171205151128) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -224,6 +224,8 @@ ActiveRecord::Schema.define(version: 20171123125346) do
|
||||||
t.string "nom"
|
t.string "nom"
|
||||||
t.string "prenom"
|
t.string "prenom"
|
||||||
t.integer "dossier_id"
|
t.integer "dossier_id"
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
t.index ["dossier_id"], name: "index_entreprises_on_dossier_id", using: :btree
|
t.index ["dossier_id"], name: "index_entreprises_on_dossier_id", using: :btree
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -419,8 +421,8 @@ ActiveRecord::Schema.define(version: 20171123125346) do
|
||||||
t.boolean "for_individual", default: false
|
t.boolean "for_individual", default: false
|
||||||
t.boolean "individual_with_siret", default: false
|
t.boolean "individual_with_siret", default: false
|
||||||
t.date "auto_archive_on"
|
t.date "auto_archive_on"
|
||||||
t.datetime "hidden_at"
|
|
||||||
t.datetime "published_at"
|
t.datetime "published_at"
|
||||||
|
t.datetime "hidden_at"
|
||||||
t.datetime "archived_at"
|
t.datetime "archived_at"
|
||||||
t.index ["hidden_at"], name: "index_procedures_on_hidden_at", using: :btree
|
t.index ["hidden_at"], name: "index_procedures_on_hidden_at", using: :btree
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
namespace :'2017_12_05_initialize_timestamps_for_entreprises' do
|
||||||
|
task set: :environment do
|
||||||
|
entreprises = Entreprise.where(created_at: nil).includes(:dossier)
|
||||||
|
|
||||||
|
puts "#{entreprises.count} to initialize..."
|
||||||
|
|
||||||
|
entreprises.each { |e| initialize_entreprise(e) }
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize_entreprise(entreprise)
|
||||||
|
puts "initializing entreprise #{entreprise.id}"
|
||||||
|
if entreprise.dossier.present?
|
||||||
|
entreprise.update_columns(created_at: entreprise.dossier.created_at, updated_at: entreprise.dossier.created_at)
|
||||||
|
else
|
||||||
|
puts "dossier #{entreprise.dossier_id} is missing for entreprise #{entreprise.id}"
|
||||||
|
entreprise.update_columns(created_at: DateTime.now, updated_at: DateTime.now)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue