Reputation: 501
i had a the following code:
from flask.ext.sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class story(db.Model):
id = db.Column(db.Integer, primary_key=True)
desc= db.Column(db.Text)
def __init__(self, desc):
self.desc= desc
and i created the db in a different file.
after the db table was created i needed to add another column to the db, so i added the following code to the "Text" class: name = db.Column(db.Text)
but when im running the project it output the following error:
OperationalError: (OperationalError) table story has no column named name
my question is: how can i change the db after it already been created?
Upvotes: 1
Views: 1907
Reputation: 1273
You can use Alembic for "automatic" migrations
http://alembic.readthedocs.org/en/latest/
Or just add the new column to the database yourself
alter table STORY add column name ....
Upvotes: 1