axsh / openvnet

Data Center Level Virtual Network Toolkit based on Edge Overlaid Network using OpenFlow 1.3.
http://openvnet.org
GNU Lesser General Public License v3.0
74 stars 18 forks source link

Paranoia unique constraints hack no longer needed #310

Open Metallion opened 9 years ago

Metallion commented 9 years ago

Problem

In the past we have patched the sequel/paranoia plugin to allow for unique constraints. Our patch is in this file over here.

Looking at the plugin today, it seems like they have solved the unique constraints issue themselves.

Solution

Refactor our code to get rid of the monkey patch and use paranoia as is again. This should not be worked on until the bundle update pull request is done in https://github.com/axsh/openvnet/pull/307.

unakatsuo commented 9 years ago

I think that what the paranoid plugin solved is different.

The reason why we set primary key ID to is_deleted Integer column is to avoid error from destroying of multiple rows. Assume that the destroy operation for two rows happen within 1 second, they will get same time value in deleted_at DateTime column and causes the unique constraint error.

This issue is database product dependent since MySQL's DataTime stores second as smallest unit but Postgres one takes much smaller time unit for equivalent column type.

Mopster commented 9 years ago

Why is there a unique constraint on the is_deleted column ?

unakatsuo commented 9 years ago

because those tables are logical deleted.