Check value if exists in column

EXISTS should normally return as soon as the subquery finds one row that satisfies its WHERE clause. So I think your query is as fast as you can make it. I was a little surprised that LIMIT 1 seems to always speed up the query very slightly. I didn’t expect that. You can see the … Read more

docker-entrypoint-initdb.d bad interpreter: Permission denied

I ended up running into this same issue. For anyone who faces this, you need to give execution permission to your script file, since Docker copies over permissions: chmod +x your/script.sh In my case the issue msg was: /opt/bitnami/scripts/libpostgresql.sh: /docker-entrypoint-initdb.d/my-initdb.sh: /bin/bash: bad interpreter: Permission denied Then I gave execution permission to my-initdb.sh and it worked … Read more

How do you do UUID in Golangs Gorm?

For postgresql, here is what I did: go get github.com/google/uuid Use uuid.UUID (from “github.com/google/uuid”), as type, e.g ID uuid.UUID `gorm:”type:uuid;default:uuid_generate_v4()”` Add uuid-ossp extension for postgres database, e.g CREATE EXTENSION IF NOT EXISTS “uuid-ossp”; Then, when you call DB’s Create() method, the uuid is generated automatically. Update: pg14+ gen_random_uuid() (as mentioned in Doron Segal‘s comment) pg … Read more

default for column “xxxx” cannot be cast automatically to type boolean in Postgres DB

You have to drop the default constraint before changing the type: ALTER TABLE parts ALTER COLUMN is_dpm_scanned DROP DEFAULT, ALTER COLUMN is_dpm_scanned TYPE BOOLEAN USING is_dpm_scanned::BOOLEAN, ALTER COLUMN is_dpm_scanned SET DEFAULT FALSE; See also: Changing a column from string to string array in PostgreSQL for a detailed explanation. How to cast varchar to boolean.

tech