Yii2 tries tu run migrations already applied - yii2

Recently a have run the php yii migrate/fresh command, later I added one new migration, when I tried to run this new one, yii marks as not applied the new migration and other 6, how can I avoid this? thanks in advance for your help.

Don't run php yii migrate/fresh and you will avoid that

Related

Domain classes and database are out of sync in Grails

I've this weird problem. I have a Grails app in which some database changelog files are missing. Therefore, the database has gone out of sync with the domain classes. I've done some changes in the domain classes. When I try to run the database migration plugin, it is creating a diff betweeb the current domain classes and the database and try to execute all the sql commands that has already been run which is causing error in executing the commands that I want to execute.
Is there is a solution for this problem?
If I understand your problem correctly, you can re-create all of the missing changelogs using dbm-generate-changelog. This will create changelogs based on the current data model. Then you can use dbm-changelog-sync to mark those changelogs as EXECUTED (which will populate the DATABASECHANGELOG table). Once the DATABASECHANGELOG table is in sync with the current data model, you can use dbm-gorm-diff to make sure you're not missing any other data model changes.
https://grails-plugins.github.io/grails-database-migration/1.4.0/ref/Maintenance%20Scripts/dbm-changelog-sync.html
NOTE: My answer assumes you're using Grails 2.x and Database Migration plugin 1.4.x, but I believe the process is similar in Grails 3.x with Database Migration Plugin 2.x or 3.x.

How to write database migration in sails.js application

I tried using https://github.com/building5/sails-db-migrate module for creating migrations but it did not run correctly. Table used to get generated but few columns were missing.
Is there a better way to create and run migrations? Sorry i am new to sails, recently migrated from Php.
So, it turn out i was stupid to think we need a module to write migration in sails. It turn out on sails lift the application automatically creates the table from attributes of the model.
But on trying that i realized the waterline module which takes care of this does not create for foreign-key constraints as of now.They are still working on it.
If you are using a nosql db then you can use the associations
http://sailsjs.org/#!/documentation/concepts/ORM
Time is pass, but nothing changes with sails. Beware use it.
If you already in this trap - try https://www.npmjs.com/package/sails-migrations
So people will get a clean and correct answer: The sails ORM (waterline) already supports auto migration, you can change this in the config file (/config/models.js):
module.exports.models = {
migrate: 'alter'
};
It accepts the following options:
safe - never auto-migrate my database(s). I will do it myself (by hand)
alter - auto-migrate, but attempt to keep my existing data (experimental)
drop - wipe/drop ALL my data and rebuild models every time I lift Sails
http://sailsjs.org/#!/documentation/concepts/ORM/model-settings.html

Rails Development with MySQL:Inserting data into tables

I downloaded a rails project.
Bundled it.
Run migrations.
Now the tables are empty. Which is the best way to fill it. irb or migrations itself. ?
You can use seeds.rb to fill the tables.
Create /db/seeds.rb
5.times do |i|
Model.create(name: "xxx")
end
And run rake db:seed.
rake db:seed
Look "Migrations and Seed Data" in rails guide.
http://guides.rubyonrails.org/migrations.html#migrations-and-seed-data
Rails has a seeds feature to populate the db with initial data, check out this guide, paragraph 8
Active Record Migrations
hope that helps
Neither of those is best way to do.You should be doing CRUD operations in order to keep your Rails project up and running.
By doing so,you should be able to create,edit,update and destroy the Records.
You have to read these Guides.You need it.

How do I test or debug my migration scripts in rails?

I am current developing a big migration script, where I need to do the following:
1- Create new columns in table_1
2- Copy the values form table_2 to the new columns created in table_1
3- Delete table_2
I developed the up and down methods for this migration. My problem is that step 2 is just not copying my data correctly I need to be able to test/debug my code as it runs.
If there is a way please let me know. I am currently using Rails 2.3.8 but If there is a way for Rails 3 or 3.1 also please let me know.
Thanks a lot
To debug your data migration, you can use the ruby-debug gem and insert a breakpoint in the migration code:
require 'ruby-debug'; debugger
Then run the rake task:
rake db:migrate:redo VERSION=whatever_version_number_your_migration_has
Quick ruby-debug tutorial here.
Manipulating data in migrations is not a good idea. They should be used only to edit database structure. But you can always rename existing table, it`s columns and add new columns to it or remove some of them. List of available actions that can be performed on database via migrations can be found at http://api.rubyonrails.org/classes/ActiveRecord/Migration.html

Subsonic 3.0.0.3 with MySQL 4template is not working

I am ready and see all the tutorials and videos to configure the subsonic 3.0.0.3 with MySql and fail to genarate the ActiveRecords.cs. I use the MySQL.ttinclude in the folder to generate the class but it is still not working. I rename all the refenreces to SQLServer.ttinclude to MySQL.ttinclude and it still does not work. The error is: Metadata file "MySql.Data" could not by found.
I really need to use the subsonic version 3.0.0.3 with MySql 5.1.
I ran into the same issue. Make sure you actually run the installer for the MySQL connector as that put everything in the GAC. I tried to get it to work by just adding the ref to MySql.Data, and I got the same error as you. Everything worked perfectly once I ran their install.
Yes, all reference is setting. The two dlls Subsonic.core.dll and MySql.Data.dll. I think that's probable a bug int the 4templates for MySql. Many people still have problems whit the version for MySql. In the videos of rob for configurin and setting MySQL generate, it still work perfectly, but the files in the pack 3.0.0.3 are different.
dunno if you got same problem but i had trouble and it was because i had a C# project but was using the VB templates and it never created the files, also i have used mysql connector 6.1 if this helps as i think this is the most compatable version when it comes to stuff like this.
Yes, Iam using MySQL Connector 6.1 whit provider. Now I try to generate my class with the 4Templates to LINQ, but I don't have success. I see this error in VStudio 2008
Warning 1 Multiple template directives were found in the template. All but the first one will be ignored. Multiple parameters to the template directive should be specified within one template directive.
When I try to generate the class with the templates for Active Record, It's works, wonderfull, but I realy need the LINQ templates class generated.