Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity field with array: true and length generates a new migration every time #3088

Closed
realyze opened this issue Nov 9, 2018 · 3 comments
Closed

Comments

@realyze
Copy link

realyze commented Nov 9, 2018

Issue type:

[ ] question
[x ] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x] postgres
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[x] latest
[x] @next
[ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:
When I add an entity field with array: true and length: <n>, migration:generate will drop and re-add the array column every time.

Small reproducible case here: https://github.com/realyze/typescript-example (problematic fields added here: https://github.com/realyze/typescript-example/blob/master/src/entity/Post.ts#L20-L27)

Big props to you for this awesome ORM, @pleerock !

@iCrawl
Copy link

iCrawl commented Nov 11, 2018

Looks similar to #3076 where certain default values have the same issue. Maybe this goes a bit deeper.

@xiaoweiColive
Copy link

Similar issue here. When I have array set to true and a length, every time I reboot the app, the data of that field will be cleared without being stored.

@AlexMesser
Copy link
Collaborator

I just checked this reproduction on the latest 0.2.36, everything works as expected:

% typeorm migration:run
query: SELECT * FROM current_schema()
query: SELECT * FROM "information_schema"."tables" WHERE "table_schema" = 'public' AND "table_name" = 'migrations'
query: SELECT * FROM "migrations" "migrations" ORDER BY "id" DESC
0 migrations are already loaded in the database.
1 migrations were found in the source code.
1 migrations are new migrations that needs to be executed.
query: START TRANSACTION
query: ALTER TABLE "public"."post" ADD "myLittleBrokenArray" character varying(25) array
query: INSERT INTO "migrations"("timestamp", "name") VALUES ($1, $2) -- PARAMETERS: [1627731077991,"aaa1627731077991"]
Migration aaa1627731077991 has been executed successfully.
query: COMMIT
% typeorm migration:run
query: SELECT * FROM current_schema()
query: SELECT * FROM "information_schema"."tables" WHERE "table_schema" = 'public' AND "table_name" = 'migrations'
query: SELECT * FROM "migrations" "migrations" ORDER BY "id" DESC
No migrations are pending

Closing because this issue most probably isn't actual anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants