migrate

flask-sqlalchemy 关系表简单操作

こ雲淡風輕ζ 提交于 2019-11-29 10:43:03
from flask import Flask from flask.ext.sqlalchemy import SQLAlchemy from flask.ext.migrate import Migrate, MigrateCommand from flask.ext.script import Manager app = Flask(__name__) app.config[ 'SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db' db = SQLAlchemy(app) migrate = Migrate(app, db) manager = Manager(app) manager.add_command( 'db', MigrateCommand) class Post(db.Model): id = db.Column(db.Integer, primary_key= True) name = db.Column(db.String( 80)) category_id = db.Column(db.Integer, db.ForeignKey( 'category.id')) category = db.relationship( 'Category', backref=db.backref( 'posts', lazy=

how to detect whether my rails is running in migration or not in environment.rb

我怕爱的太早我们不能终老 提交于 2019-11-29 09:17:07
any easy way to detect it? I want to skip some codes in envirmonment.rb when doing migration rake. I had this problem in a legacy application I was maintaining. There were some observers that were interfering with migrations past a certain point, so I disabled them during migration by checking the application name and arguments # Activate observers that should always be running # config.active_record.observers = :cacher, :garbage_collector, :forum_observer# observers break a migrate from VERSION xxx - disable them for rake db:migrate unless ( File.basename($0) == "rake" && ARGV.include?("db

Django - no such table exception

纵然是瞬间 提交于 2019-11-29 07:53:51
问题 In Django, I've added some models into models.py . After manage.py makemigrations , manage.py migrate raised this exception: django.db.utils.OperationalError: no such table: auth_test_usertranslatorprofile So I've removed all old migrations and run makemigrations and migrate again which seemed to work. Unfortunately, I've noticed that it didn't helped because when I try to click on User customer profiles of User translator profiles it raises exception: Environment: Request Method: GET Request

Django 1.8 RC1: ProgrammingError when creating database tables

*爱你&永不变心* 提交于 2019-11-29 03:43:25
I'm using AbstractBaseUser for my user models in various projects. Updating to Django 1.8 RC1 works smoothly and I can run the migrate management command. However, when trying to create a fresh database table layout from scratch, I get the following error: python manage.py migrate >>> ... >>> ... >>> django.db.utils.ProgrammingError: relation "auth_group" does not exist All works perfectly with Django 1.7.x and I cannot find anything about this issue elsewhere. So, is it a big with the RC1 version or did something change that I'm not aware of in Django 1.8? Unfortunately, the error message

How to change schema of multiple PostgreSQL tables in one operation?

99封情书 提交于 2019-11-28 17:04:40
I have a PostgreSQL 9.1 database with 100 or so tables that were loaded into the 'public' schema. I would like to move those tables (but not all of the functions in 'public') to a 'data' schema. I know that I can use the following to move 1 table at a time. ALTER TABLE [tablename] SET SCHEMA [new_schema] Is it possible to move all of the tables to the new schema in one operation? If so, what would be the most efficient way to accomplish this task? DO will do the trick: DO $$ DECLARE row record; BEGIN FOR row IN SELECT tablename FROM pg_tables WHERE schemaname = 'public' -- and other conditions

How to efficiently manage frequent schema changes using sqlalchemy?

拟墨画扇 提交于 2019-11-28 14:25:23
问题 I'm programming a web application using sqlalchemy. Everything was smooth during the first phase of development when the site was not in production. I could easily change the database schema by simply deleting the old sqlite database and creating a new one from scratch. Now the site is in production and I need to preserve the data, but I still want to keep my original development speed by easily converting the database to the new schema. So let's say that I have model.py at revision 50 and

Django datetime migration error

两盒软妹~` 提交于 2019-11-28 11:54:08
问题 I don't think anything in my model has changed. I have reverted it back to times when it was all fully functional and I still get the following errors. There are my models: class UserProfile(models.Model): # This line is required. Links UserProfile to a User model instance. user = models.OneToOneField(User) # The additional attributes we wish to include. website = models.URLField(blank=True) picture = models.ImageField(upload_to='profile_images', blank=True) # Override the __unicode__()

mysql server has gone away error during installing migration (laravel)

耗尽温柔 提交于 2019-11-28 07:59:10
问题 So I am using my cmd on my laravel folder and I tried to do (php artisan migrate:install). 2 errors came up. [PDOException] SQLSTATE[HY000] [2006] MySQL server has gone away [ErrorException] PDO::__construct(): MySQL server has gone away Can anyone please explain what I did wrong? 回答1: This is not a Laravel issue, but a general MySQL Issue. Maybe the server is not running. Are you sure you're running MySQL in the background? Check this link: MySQL Gone Away Do the following checks in your

SyntaxError: Generator expression must be parenthezised / python manage.py migrate

我怕爱的太早我们不能终老 提交于 2019-11-28 06:44:34
I'm really new in programming and I wanted to follow the Djangogirls tutorial, but I'm stucked now. In the tutorial, I am here : To create a database for our blog, let's run the following in the console: python manage.py migrate (we need to be in the djangogirls directory that contains the manage.py file). If that goes well, you should see something like this: ... There is no option to fail in the tutorial but I have an error message: (myvenv) C:\Users\Julcsi\djangogirls> python manage.py migrate Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command

how to detect whether my rails is running in migration or not in environment.rb

ε祈祈猫儿з 提交于 2019-11-28 02:42:22
问题 any easy way to detect it? I want to skip some codes in envirmonment.rb when doing migration rake. 回答1: I had this problem in a legacy application I was maintaining. There were some observers that were interfering with migrations past a certain point, so I disabled them during migration by checking the application name and arguments # Activate observers that should always be running # config.active_record.observers = :cacher, :garbage_collector, :forum_observer# observers break a migrate from