No unique or exclusion constraint matching the ON CONFLICT

Per the docs, All table_name unique indexes that, without regard to order, contain exactly the conflict_target-specified columns/expressions are inferred (chosen) as arbiter indexes. If an index_predicate is specified, it must, as a further requirement for inference, satisfy arbiter indexes. The docs go on to say, [index_predicate are u]sed to allow inference of partial unique indexes … Read more

PostgreSQL INSERT ON CONFLICT UPDATE (upsert) use all excluded values

Postgres hasn’t implemented an equivalent to INSERT OR REPLACE. From the ON CONFLICT docs (emphasis mine): It can be either DO NOTHING, or a DO UPDATE clause specifying the exact details of the UPDATE action to be performed in case of a conflict. Though it doesn’t give you shorthand for replacement, ON CONFLICT DO UPDATE … Read more

Postgresql – unable to drop database because of some auto connections to DB

You can prevent future connections: REVOKE CONNECT ON DATABASE thedb FROM public; (and possibly other users/roles; see \l+ in psql) You can then terminate all connections to this db except your own: SELECT pid, pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = current_database() AND pid <> pg_backend_pid(); On older versions pid was called procpid so you’ll have … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)