Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How we can migrate database in sqlmodel?

class Hero(SQLModel, table=True):
    id: int = Field(primary_key=True)
    name: str
    age: int = Field(default=None)
    status:str

I created the table using SQLModel.metadata.create_all(engine), when I changed the type of status to str and run the create_all() method again the type of status did not change in the database. Is there any way to migrate the database like Django or flask-migrate?

like image 317
faris404 Avatar asked May 30 '26 11:05

faris404


1 Answers

The fastest way is to drop the table manually and reload the app.

But if you want a more automated and reliable solution check the following link:

https://github.com/tiangolo/sqlmodel/issues/85

like image 133
Kostas Nitaf Avatar answered Jun 02 '26 00:06

Kostas Nitaf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!