テーブルの列と列のデータ型をPeeWeeに更新するにはどうすればよいですか?既存のテーブル/モデルの列/フィールドを更新しますか?
私はすでにPerson
テーブルを自分のモデルからデータベースに作成しました。しかし、モデルにいくつかの新しいフィールドを追加し、既存のフィールド/カラムのタイプを変更しました。
次は、テーブル構造は更新されません:ドキュメントから
psql_db = PostgresqlExtDatabase(
'MyDB',
user='foo',
password='bar',
host='',
port='5432',
register_hstore=False
)
class PsqlModel(Model):
"""A base model that will use our Postgresql database"""
class Meta:
database = psql_db
class Person(PsqlModel):
name = CharField()
birthday = DateField() # New field
is_relative = BooleanField() # Field type changed from varchar to bool
def __str__(self):
return '%s, %s, %s' % (self.name, self.birthday, self.is_relative)
psql_db.connect()
# is there a function to update/change the models table columns??
psql_db.create_tables([Person], True) # Hoping an update of the table columns occurs
# Error because no column birthday and incorrect type for is_relative
grandma_glen = Person.create(name='Glen', birthday=date(1966,1,12), is_relative=True)