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

Connection.synchronize(dropbeforeSync) how to set to true #1861

Closed
Freysi21 opened this issue Mar 31, 2018 · 2 comments
Closed

Connection.synchronize(dropbeforeSync) how to set to true #1861

Freysi21 opened this issue Mar 31, 2018 · 2 comments

Comments

@Freysi21
Copy link

Issue type:

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

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[x] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] sqlite
[ ] sqljs
[ ] websql

TypeORM version:

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

Steps to reproduce or a small repository showing the problem:
Hi

I'm having difficulties with letting typeorm create my database.
This keeps coming up "ER_CANT_REMOVE_ALL_FIELDS: You can't delete all columns with ALTER TABLE; use DROP TABLE instead".

I did some digging and found a the "dropbeforeSync" parameter in Connection.synchronize method which was always false. I added a line of code into node_modules/typeorm/browser/Connection.js that set that bastard to true. Now I'm able to create all tables and everything works fine 👍

My question is how do i come about to setting this to true without needing to modify

@Freysi21
Copy link
Author

Also might be worth a mention.

CREATE TABLE measurement(
ID INT AUTO_INCREMENT NOT NULL ,
NAME VARCHAR(100),
PRIMARY KEY(ID)
);
This is the table definition that was being "ALTERED" and resulted in an exception.

@Freysi21
Copy link
Author

found my answer here
#18

I should call connection.synchronize(true); after creating connection.

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

No branches or pull requests

1 participant