Postgres constraint for unique datetime range

You can keep your separate timestamp columns and still use an exclusion constraint on an expression: CREATE TABLE tbl ( tbl_id serial PRIMARY KEY , starts_at timestamp , ends_at timestamp , EXCLUDE USING gist (tsrange(starts_at, ends_at) WITH &&) — no overlap ); Constructing a tsrange value without explicit bounds as tsrange(starts_at, ends_at) assumes default bounds: … Read more

PHP mutual exclusion (mutex)

Well, most of PHP runs in a different process space (there are few threading implementations). The easy one is flock. It’s guaranteed to work on all platforms. However, if you compile in support, you can use a few other things such as the Semaphore extension. (Compile PHP with –enable-sysvsem). Then, you can do something like … Read more