diff options
| author | Teddy Wing | 2017-11-24 19:18:25 +0100 | 
|---|---|---|
| committer | Teddy Wing | 2017-12-06 15:30:58 +0100 | 
| commit | 5ae238936d3c91e70709c2ec4ed8a73a6f4524dc (patch) | |
| tree | 693481c2b4085695e5c4382031025cac7f1b6802 /app/models/referential.rb | |
| parent | 0ec72aa1ce6598f48943df33827a6d700ee15153 (diff) | |
| download | chouette-core-5ae238936d3c91e70709c2ec4ed8a73a6f4524dc.tar.bz2 | |
Referential: Move `create_schema` to an `after_commit`
The goal being to separate the creation of the database schema from the
creation of the `Referential` object. Previously these were created in
the same database transaction, but moving the schema to an
`after_commit` puts it in a separate transaction.
This change tries to mitigate a problem where two `Referential`s,
created at the same time with the same data, can be saved, even though
identical `Referential`s should not be allowed. By moving the schema
creation to a separate transaction, we decrease the time it takes to
create a `Referential`, increasing the odds of not creating two
identical `Referential`s due to near-simultaneous writes.
Refs #5024
Conflicts:
	app/models/referential.rb
Diffstat (limited to 'app/models/referential.rb')
| -rw-r--r-- | app/models/referential.rb | 2 | 
1 files changed, 1 insertions, 1 deletions
| diff --git a/app/models/referential.rb b/app/models/referential.rb index f89eafee8..d090a3f7c 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -200,8 +200,8 @@ class Referential < ActiveRecord::Base    # to minimise the duration of the lock.    before_validation :lock_table, on: :create -  before_create :create_schema    after_create :clone_schema, if: :created_from +  after_commit :create_schema    before_destroy :destroy_schema    before_destroy :destroy_jobs | 
