database-migration

Rails initializers are running while migrating database

别来无恙 提交于 2019-12-04 01:59:37
It is very surprising that Rails's initializers run while running any rake task, including db:migrate and db:seed . An initializer in my app starts a background thread (a kind of worker process), and it should be executed only when the application is running in debug and production mode. How to prevent a specific initializer from running when doing rake db:migrate or how to detect in initializer that a rake task is running? Here is a solution how to prevent an initializer from running in Rake task: unless ( File.basename($0) == 'rake') # Initializer code end Alessandro Gurgel If your

Run alembic upgrade migrations in a transaction

人盡茶涼 提交于 2019-12-04 00:40:38
问题 Does alembic upgrade head run inside a transaction so that all database alterations succeed, or fail? If not, why was it designed this way? 回答1: My understanding is alembic runs inside a transaction for databases that support it, like Postgres. If you're on a database that does not support this ( cough MySQL cough ), you can't use this functionality. 回答2: That's something you can decide within the env.py , which is where you customize the behaviour of the migrations to suit your setup. You

Parse migration to heroku/aws regarding the image

荒凉一梦 提交于 2019-12-03 20:19:35
I have successfully migrated my parse db to aws but the urls of image files still like http://files.parsetfss.com/77447afb-f681-4b55-afad-6bceeb2e155a/tfss-79297c86-bd48-4d7f-87ab-c43e02d1a8f3-photo.png it means files are still on parse s3 cloud or something their own storage so what will happen to those files after parse shutdown. what is the way to migrate the images to new database/storage on my own AWS. I am worried because I have apprx 14.5 k images on parse. Please provide you valuable guidance on this. As you know, Parse Files is a feature allowing developers to upload files (up to 10

What is a good workflow for database migration in Grails?

落花浮王杯 提交于 2019-12-03 15:46:14
I want to use the database-migration grails plugin for database migration. When I start my Grails app the first time all the database tables are created automatically. The production setting in my DataSource.groovy is: production { dataSource { dbCreate = "update" url = "jdbc:mysql://localhost/myapp?useUnicode=yes&characterEncoding=UTF-8" username = "test" password = "test" dialect = org.hibernate.dialect.MySQL5InnoDBDialect properties { validationQuery = "select 1" testWhileIdle = true timeBetweenEvictionRunsMillis = 60000 } } } In my config.groovy I set: grails.plugin.databasemigration

Changing Django database backend from MySql to PostgreSQL

给你一囗甜甜゛ 提交于 2019-12-03 13:56:54
问题 I use Django 1.2 and 1.3 and MySql backends. Once in while a get an error message when migrating my MySql database with South: ! Error found during real run of migration! Aborting. ! Since you have a database that does not support running ! schema-altering statements in transactions, we have had ! to leave it in an interim state between migrations. ... ! The South developers regret this has happened, and would ! like to gently persuade you to consider a slightly ! easier-to-deal-with DBMS I

How to migrate Django models from mysql to sqlite (or between any two database systems)?

℡╲_俬逩灬. 提交于 2019-12-03 13:10:01
问题 I have a Django deployment in production that uses MySQL. I would like to do further development with SQLite, so I would like to import my existing data to an SQLite database. I There is a shell script here to convert a general MySQL dump to SQLite, but it didn't work for me (apparently the general problem isn't easy). I figured doing this using the Django models must be much easier. How would you do this? Does anyone have any script to do this? 回答1: use manage.py dumpdata > your_file.json to

Migrating from Cake 1.3 to 2.0 and beyond - migrate existing, or only use for new?

半城伤御伤魂 提交于 2019-12-03 11:07:18
I'm nearling completion of my first CakePHP-driven website and just saw they're already working on CakePHP 2.0 (not the stable release yet). My questions: Is it incredibly time consuming to move to a new version of CakePHP (when it becomes the "stable" release that is)? I know they have migration guides, but - I've never used a framework before, so I've never had to migrate anything. Do you migrate your code for existing projects, or leave it as is and use the new stable version for future projects only? Where can I find what version of CakePHP I currently have installed? I've looked at the

Doctrine2 Migration Using DBAL instead of $this->addSql

…衆ロ難τιáo~ 提交于 2019-12-03 10:53:51
So I've done a bunch of Doctrine2 migrations (https://github.com/doctrine/migrations) but I have a question for a new migration I'm trying to do. I've been digging into the library a little and I see that $this->addSql() is used to build a list of SQL to execute and then it gets executed later. I wanted to do something where I select some data, iterate over the rows, insert new data based on that, and then delete the data I selected. This lends itself to the DBAL library pretty easily, but I'm wondering, can I use the protected $connection in a migration safely? Or is that bad because it would

Add “ON DELETE CASCADE” to existing column in Laravel

天涯浪子 提交于 2019-12-03 10:35:58
问题 I have user_id fk column in my table $table->foreign('user_id')->references('id')->on('users'); I should add on cascade delete feature to this existing column. How can I do this? 回答1: Drop foreign key first. Thanks to Razor for this tip $table->dropForeign('answers_user_id_foreign'); $table->foreign('user_id') ->references('id')->on('users') ->onDelete('cascade'); 回答2: Laravel schema builder can't modify columns at the current state, so you will use raw queries. You will have to drop and

Stop Django from creating migrations if the list of choices of a field changes

狂风中的少年 提交于 2019-12-03 10:22:29
I have a django core app called "foocore". There are several optional pluging-like apps. For example "superfoo". In my case every plugin adds a new choice in a model CharField which belongs to "foocore". Django migrations detect changes if the list of choices get changed. I think this is not necessary. At least one other developer thinks the same: https://code.djangoproject.com/ticket/22837 class ActivePlugin(models.Model): plugin_name = models.CharField(max_length=32, choices=get_active_plugins()) The code to get the choices: class get_active_plugins(object): def __iter__(self): for item in .