Md. Sakhawath Hossain
Md. Sakhawath Hossain

Reputation: 441

How to stop Auto Migration of Database table in Go

I am trying to build an api in beego. I have to make a controller and a model for this project. Model has a database table but the table is not in my database. Beego automatically creates the table in the database. How can I stop it.

Upvotes: 0

Views: 272

Answers (1)

Bratix
Bratix

Reputation: 71

I imagine you are using this command err := orm.RunSyncdb(name, force, verbose). This command looks for changes in your models and if there are any drops the database and creates a new one. If you want to stop it simply don't use this command and write database migrations for your app with bee generate migration migration_name. In the file you have to run the required sql to create the tables. After writing your migrations run bee migrate -conn="{your_database_connection_string}".

Upvotes: 0

Related Questions