This repo demonstrates a problem with Typeorm synchronization of array of varchars on Postgres.
When using Postgres, if a length is specified for an array of type varchar and synchronization is enabled, Typeorm will drop and re-add the column on startup even if there are no schema changes.
If the length property is removed, the behavior will stop occurring.
- Clone the repo.
- Configure a postgres database 'test' and schema 'test' with owner 'test' and password 'test', or update ormconfig.json as needed.
- npm install
- npm run start (calls the compiler and executes index.js twice)
Excerpt of console output for second execution of index.js:
query: ALTER TABLE "test"."user" DROP COLUMN "roles"
query: ALTER TABLE "test"."user" ADD "roles" character varying(64) array NOT NULL