You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from peewee import *
import peeweedbevolve
db = MySQLDatabase('test', user='root', password='', host='127.0.0.1', port=3307)
class Art(Model):
name = CharField()
class Meta:
database = db
table_name = 'arts'
class User(Model):
class Meta:
database = db
table_name = 'users'
name = CharField()
art = ForeignKeyField(Art)
if __name__ == '__main__':
db.evolve()
First launch
console:
Making updates to database: family_bot
Your database needs the following changes:
CREATE TABLE IF NOT EXISTS `arts` (`id` INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` VARCHAR(255) NOT NULL);
CREATE TABLE IF NOT EXISTS `users` (`id` INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` VARCHAR(255) NOT NULL, `art_id` INTEGER NOT NULL);
ALTER TABLE `users` ADD CONSTRAINT `fk_users_art_id_refs_arts` FOREIGN KEY (`art_id`) REFERENCES `arts` (`id`);
CREATE INDEX `user_art_id` ON `users` (`art_id`);
Do you want to run these commands? (yes or no) yes
Running in 3... 2... 1...
CREATE TABLE IF NOT EXISTS `arts` (`id` INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` VARCHAR(255) NOT NULL);
CREATE TABLE IF NOT EXISTS `users` (`id` INTEGER AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` VARCHAR(255) NOT NULL, `art_id` INTEGER NOT NULL);
ALTER TABLE `users` ADD CONSTRAINT `fk_users_art_id_refs_arts` FOREIGN KEY (`art_id`) REFERENCES `arts` (`id`);
CREATE INDEX `user_art_id` ON `users` (`art_id`);
SUCCESS! - https://github.com/keredson/peewee-db-evolve
Process finished with exit code 0
And every time I start up I get this:
Making updates to database: family_bot
Your database needs the following change:
ALTER TABLE `users` ADD CONSTRAINT `fk_users_art_id_refs_arts` FOREIGN KEY (`art_id`) REFERENCES `arts` (`id`);
Do you want to run this command? (yes or no)
The text was updated successfully, but these errors were encountered:
models.py:
First launch
console:
And every time I start up I get this:
The text was updated successfully, but these errors were encountered: