database-migration

Laravel's Artisan says nothing to migrate

╄→尐↘猪︶ㄣ 提交于 2019-12-03 09:29:56
I installed migrations with php artisan migrate:install then created a migration with the php artisan migrate:make create_teams_table command. Now I try to run them with the following command that I made according to the official documentation : php artisan migrate --path=app/foo/migrations/2014_01_21_143531_create_teams_table.php This gives me the following on the console: Nothing to migrate. The migrations table in the database is empty and the new table isn't created neither. I don't understand why the documentation says foo in the path. What does foo mean and where does it comes from?

Purpose and semantic of IMigrationMetadata interface in Entity Framework

懵懂的女人 提交于 2019-12-03 07:12:51
I'm trying to find out what is the semantic of System.Data.Entity.Migrations.Infrastructure.IMigrationMetadata interface in the EF. I know that it's used to manage and apply DB migrations. But I can't find detailed information about it. To be specific I would like to know: What Source property is used for? Why it's always null when I generate migrations using tools? What Target property is used for? I see that tools is generating something Base64-looking and placed into resources. What is it? Why it's generated in such non-friendly format? Is it possible to develop migration manually without

Laravel Fatal Error Class Not Found when migrating

戏子无情 提交于 2019-12-03 06:59:31
问题 I've run artisan migrate:reset . I've deleted some of my migration files because I didn't need these tables anymore. I ran composer dump-autoload followed by artisan dump-autoload I ran artisan migrate and I keep getting this error: PHP Fatal error: Class 'Foo' not found in /vagrant/LaravelBackend/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php on line 297 I tried to: Run again composer dump-autoload and artisan dump-autoload (also used artisan clear-compiled ) Remove

Option for Cascade Delete for References or On Delete

社会主义新天地 提交于 2019-12-03 06:40:16
问题 In Rails 4.2, when creating a table or adding a reference via references or add_reference how do you specify that the foreign key should cascade on delete. Command to generate scaffold: rails g scaffold Child parent:references name:string Resulting migration: create_table :childs do |t| t.references :parent, index: true, foreign_key: true t.string :name t.timestamps null: false end 回答1: This should work create_table :childs do |t| t.references :parent, index: true, foreign_key: {on_delete:

EF migration shows empty Up() Down() methods

拥有回忆 提交于 2019-12-03 06:28:18
问题 I have a local database that is currently in it's second version and should now go to it's third version. The code for the previous migrations was generated by another programmer so I am assuming I am doing something wrong here. In my model there are around 30 classes, and inside the model folder there is a mapping folder and it contains the mappings for those 30 classes. So now I added 1 new class in the same manner as those previous classes and then run the add-migration command in the

Managing mongoid migrations

前提是你 提交于 2019-12-03 04:15:10
问题 Can someone give me a short introduction to doing DB migrations in Rails using Mongoid? I'm particularly interested in lazy per document migrations. By this, I mean that whenever you read a document from the database, you migrate it to its latest version and save it again. Has anyone done this sort of thing before? I've come across mongoid_rails_migrations, but it doesn't provide any sort of documentation, and although it looks like it does this, I'm not really sure how to use it. I should

Changing Django database backend from MySql to PostgreSQL

微笑、不失礼 提交于 2019-12-03 03:48:28
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 was wondering if migrating my databases from MySql to PostgreSQL might prevent this error. Secondly,

Running migrations with Rails in a Docker container with multiple container instances

。_饼干妹妹 提交于 2019-12-03 03:39:26
问题 I've seen lots of examples of making Docker containers for Rails applications. Typically they run a rails server and have a CMD that runs migrations/setup then brings up the Rails server. If I'm spawning 5 of these containers at the same time, how does Rails handle multiple processes trying to initiate the migrations? I can see Rails checking the current schema version in the general query log (it's a MySQL database): SELECT `schema_migrations`.`version` FROM `schema_migrations` But I can see

Django 1.8 - what's the difference between migrate and makemigrations?

纵饮孤独 提交于 2019-12-03 02:38:56
问题 According to the documentation here: https://docs.djangoproject.com/en/1.8/topics/migrations/ it says: migrate, which is responsible for applying migrations, as well as unapplying and listing their status. and makemigrations, which is responsible for creating new migrations based on the changes you have made to your models. From what I understand, I first do makemigrations to create the migration file and then do migrate to actually apply the migration? Do note though that I just began my

Add “ON DELETE CASCADE” to existing column in Laravel

自古美人都是妖i 提交于 2019-12-03 01:12:18
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? 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'); Laravel schema builder can't modify columns at the current state, so you will use raw queries. You will have to drop and recreate the constraint : PostgreSQL function up() { DB::statement('alter table answers drop constraint answers_user