Download presentation
Presentation is loading. Please wait.
Published byArline Miles Modified over 9 years ago
1
Migrations Carol Wolf CS 396X
2
ISBNTitleAuthorImage 1234-5678EmmaAustenemma.jpg 2345-6789Oliver TwistDickenstwist.jpg 3456-7890HamletShakespearehamlet.jpg Relational Databases A relational database consists of a number of different tables. Each table is like a two dimensional array. The columns show the attributes (fields) of the data. The rows each store information about a single item. The first column stores the ISBNs for each book. The first row stores information about Emma by Jane Austen.
3
Creating a table in Rails InstantRails supplies an empty database called development.sqlite3. A table is created by a migration. ruby script/generate scaffold book isbn:string author:string title:string The resulting table will be called books and have the three columns named, above each holding a string. It will also have several other columns supplied by Rails. A primary key called id of type integer. Timestamps of type date. Rails gives the resulting Ruby program a name beginning with a timestamp, 20080805165427_create_books.rb.
4
Migration file to create a new table. class CreateBooks < ActiveRecord::Migration def self.up create_table :books do |t| t.string :isbn t.string :author t.string :title t.timestamps end def self.down drop_table :books end
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.