database-migration

Rails initializers are running while migrating database

女生的网名这么多〃 提交于 2019-12-05 18:13:27
问题 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? 回答1: Here is a solution how to prevent an initializer from running in

How to migrate MySQL data directory in docker container?

落花浮王杯 提交于 2019-12-05 16:48:59
问题 I have a docker container running MySQL-5.5 with host data volume. I am upgrading my container to MySQL-5.6. I am starting a new container with the same host volume. MySQL was crashing in the container due to the crash of mysql.user table. [ERROR] Fatal error: Can't open and lock privilege tables: Incorrect key file for table 'user'; try to repair it 160523 12:04:13 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended I tried the following to fix that: root@container# mysqld -

Laravel migrations: dropping a specific table

北慕城南 提交于 2019-12-05 15:41:17
Is there any way/laravel-command to drop a specific table from the production server? Set up a migration. Run this command to set up a migration: php artisan make:migration drop_my_table Then you can structure your migration like this: <?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class DropMyTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { // drop the table Schema::dropIfExists('my_table'); } /** * Reverse the migrations. * * @return void */ public function down() { // create the table Schema::create

Best practice for SQL Server 2008 schema change

拥有回忆 提交于 2019-12-05 10:23:20
I am looking for information concerning the following: What are the best practices for updating the schema of my dev DB to my production DB, or even more succinctly making DB schema changes in general. The production database is the back-end for two distinct ASP.NET websites. Our schema change process is fairly robust with each "migration" actually being a .cs file containing the schema changes. We will then use ADO.NET to apply the schema changes against the db. My question is more about the connectivity of the database. Should I stop the two websites that are accessing the db. I assume I

Django: loaddata in migrations errors

不想你离开。 提交于 2019-12-05 09:57:39
Something really annoying is happening to me since using Django migrations (not south) and using loaddata for fixtures inside of them. Here is a simple way to reproduce my problem: create a new model Testmodel with 1 field field1 (CharField or whatever) create an associated migration (let's say 0001 ) with makemigrations run the migration and add some data in the new table dump the data in a fixture testmodel.json create a migration with call_command('loaddata', 'testmodel.json') : migration 0002 add some a new field to the model: field2 create an associated migration ( 0003 ) Now, commit that

How to remove an app from a django projects (and all its tables)

故事扮演 提交于 2019-12-05 07:07:34
I want to remove an app from a django project. I want to remove the tables of the app the content-types foreign-key usages of these content-types Running manage.py migrate app_to_remove zero does not work: django.db.migrations.migration.IrreversibleError: Operation <RunPython <function forwards_func at 0x7ff76075d668>> in fooapp.0007_add_bar is not reversible I guess there are several migrations which are not reversible ... First: Remove references in the code remove app_to_remove from settings.INSTALLED_APPS remove other references in urls.py or other places Second: Clean the database Create

Roughly how fast is JSON -> JSONB column conversion in Postgres 9.4

梦想的初衷 提交于 2019-12-05 04:05:56
I'm looking to migrate from Postgres 9.3 to 9.4, and have a lot of data in JSON columns. While it's fine, I wanted to have a look at migrating to the more efficient column storage (which JSONB seems to be — a really exciting piece of tech!). To actually migrate, I want to know migration characteristics for something like ALTER TABLE table_with_json ALTER COLUMN my_json SET DATA TYPE jsonb USING my_json::jsonb; (from this helpful question ). Ideally, it would be good to know how long it takes to migrate 1mil and 10mil entries, and how it scales. While I can get these numbers myself, I thought

SQL Server 2014 backup to 2012

喜你入骨 提交于 2019-12-05 01:44:11
Are there any tools to convert SQL Server 2014 database to 2012? I tried Generate Script but the generated script with data is too large and SQL Server Management Studio did not execute it, I need to have both schema and data. To my knowledge, there are basically three two options for migrating a database to a lower version of SQL Server, without using 3rd party tools: Generate Scripts (not really suitable for large amounts of data) Custom Scripting and BCP or Import/Export Wizard SQL Server Integration Services (Transfer Database Task) First option is not suitable in your case, as noted.

Laravel 4 Migration error - creates two auto_increment primary keys fields

蹲街弑〆低调 提交于 2019-12-05 01:04:46
I made a migration with this setup: $table->increments('id'); $table->integer('user_id', 10)->unsigned(); // this is meant to be used as a foreign key After doing php artisan migrate it returns an error: [Exception] SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto column and it must be defined as a key (SQL: create table `transactions` (`id` int unsigned not null auto_increment primary key, `user_id` int unsigned not null auto_increment primary key) default character set utf8 collate utf8_unicode_ci) (Bindings: array ()) I didn't

Django NodeNotFoundError during migration

别说谁变了你拦得住时间么 提交于 2019-12-04 23:46:43
The error I get when I try to runserver for my django app is as follows: django.db.migrations.graph.NodeNotFoundError: Migration tasks.0001_initial dependencies reference nonexistent parent node (u'auth', u'0007_alter_validators_add_error_messages') This happened after I followed this heroku tutorial: https://devcenter.heroku.com/articles/getting-started-with-django I modified the settings file to include: import dj_database_url SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') import os BASE_DIR = os.path.dirname(os.path.abspath(__file__)) STATIC_ROOT = 'staticfiles' DATABASES = {