• Struts
  • jQuery
  • JavaScript
  • RubyonRails
  • Core Java
  • Spring
  • Servlet
  • SQL Tutorial
  • JSP

  • <

    Ruby on Rails Migrations



    Migrations are a way to alter database schema over time in a consistent and organized manner. They use a Ruby DSL through which there is no need to write SQL by hand.
    SQL fragments can be edited by hand but then you have to tell other developers about the changes you made and then run them. You need to keep track of changes that need to be run against production machines next time you deploy.
    Each migration is a new version of the database. Each migration modifies database by adding or removing tables, columnns or entries. Active record will update your db/schema.rb file to match up-to-date structure of your database.

    Why Use Migrations


    It is important to know the purpose of migration before using it. Database is used in all web applications.
    Generally, a SQL statement is used to run database queries to create, modify, read or delete columns of a database.
    Migration file contains a specific set of instructions for how a database should be created. When this file is run, Rails will make changes in the database automatically. Gradually, the migration file will act as a versioned history of how database has changed. It implies that you will be able to recreate the database from the set of instructions file.

    Syntax:
    
    application_dir> rails generate migration table_name
    
    
















    © copyright 2017-2021 Completedone pvt ltd.