database-migration

Using a Repo in an Ecto migration

守給你的承諾、 提交于 2020-05-15 09:42:27
问题 I've got an Ecto migration where I'd like to modify some columns but also migrate some data. For example: import Ecto.Query defmodule MyApp.Repo.Migrations.AddStatus do alter table(:foo) do add(:status, :text) end foos = from(f in MyApp.Foo, where: ...) |> MyApp.Repo.all Enum.each(foos, fn(foo) -> # There's then some complex logic here to work # out how to set the status based on other attributes of `foo` end) end Now, the problem here is that by calling MyApp.Repo.all the migration

Using a Repo in an Ecto migration

旧街凉风 提交于 2020-05-15 09:41:33
问题 I've got an Ecto migration where I'd like to modify some columns but also migrate some data. For example: import Ecto.Query defmodule MyApp.Repo.Migrations.AddStatus do alter table(:foo) do add(:status, :text) end foos = from(f in MyApp.Foo, where: ...) |> MyApp.Repo.all Enum.each(foos, fn(foo) -> # There's then some complex logic here to work # out how to set the status based on other attributes of `foo` end) end Now, the problem here is that by calling MyApp.Repo.all the migration

sequelize.sync({ force: true }) is not working some times

╄→гoц情女王★ 提交于 2020-05-15 05:19:24
问题 i am using gulp tasks for migration of database. For testing purpose i am using different database. so i need exactly same database. i am trying to do with sequelize.sync({ force: true }) but its not working. i am having my all models in portal-model. here is the code: const models = require('portal-models'); gulp.task('migrate', ['create-database'], (done) => { models.sequelize.query('SET FOREIGN_KEY_CHECKS = 0') .then(() => models.sequelize.sync({ force: true, alter: true })) .... .... ....

sequelize.sync({ force: true }) is not working some times

久未见 提交于 2020-05-15 05:19:06
问题 i am using gulp tasks for migration of database. For testing purpose i am using different database. so i need exactly same database. i am trying to do with sequelize.sync({ force: true }) but its not working. i am having my all models in portal-model. here is the code: const models = require('portal-models'); gulp.task('migrate', ['create-database'], (done) => { models.sequelize.query('SET FOREIGN_KEY_CHECKS = 0') .then(() => models.sequelize.sync({ force: true, alter: true })) .... .... ....

What is the difference between south migrations and django migrations?

随声附和 提交于 2020-04-12 12:02:10
问题 Can anyone please explain me the difference between south migrations and django migrations? What advantage/disadvantage one has over another? 回答1: South is a third part django app that added support for migrations before a builtin migration solution was introduced in Django 1.7. Unless you're stuck with a long-dead Django version, there's no reason you should use South at all. FWIW, just checking the south project's page should have answered your question: South has been deprecated. From

How does django know which migrations have been run?

我是研究僧i 提交于 2020-03-18 03:08:21
问题 How does django know whether a migration has been applied yet? It usually gets it right, but when it doesn't I don't ever know where to start troubleshooting. 回答1: Django writes a record into the table django_migrations consisting of some information like the app the migration belongs to, the name of the migration, and the date it was applied. 回答2: You can simply use showmigrations command to provide a list of migrations $ python manage.py showmigrations whether or not each migration is

Flyway repair throws FlywaySqlException with Oracle DB

Deadly 提交于 2020-02-23 07:43:05
问题 I am trying to use flyway repair method to delete unsuccessful migration entries from schema versioning table with spring boot configuration. My code is like this; @Bean public FlywayMigrationStrategy repairStrategy() { return flyway -> { flyway.repair(); flyway.migrate(); }; } But after run, it throws an error like this(repair operation fails even when migration operation is commented out); Error while retrieving the list of applied migrations from Schema History table SQL State : 72000

Run database migration (mongodb) with node.js

时光怂恿深爱的人放手 提交于 2020-02-01 17:39:26
问题 I'm looking for a node module to make mongo database migrations. So far I found mongo-migrate , but not really powerful enough. (Better than nothing but I need more, I'm used to use the Ruby migration which was really powerful!) I found another one few weeks ago, powerful but doesn't deal with mongoDb, only with MySQL, PostGre and so on. Do you know a module or something that could help me? I mean, I'm not the first person to want to deal with DB migrations, how do you manage that? My project

SQLSTATE[HY000]: General error: 1005 during a migration in Laravel

空扰寡人 提交于 2020-01-24 13:54:26
问题 I am using Laravel 6. I want to run my migration files but during the migration of my "create_users_table" file appears the following error: SQLSTATE[HY000]: General error: 1005 Can't create tab le `thenewmeetingapp`.`#sql-f3c_b8` (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table `users` add constraint `users_permission_id_foreign` foreign key (`permission_id`) references `permissions` (`id`)) I think the error is between the table "users" and the table

Laravel migrations: dropping a specific table

℡╲_俬逩灬. 提交于 2020-01-23 08:39:06
问题 Is there any way/laravel-command to drop a specific table from the production server? 回答1: 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'); } /