I recently made the leap from SQlite3 to PostgreSQL for compatibility with Heroku. Apon researching I noticed there are differences in datatypes across each and I really don't want to mess anything up. I was wondering how I could make the following migration compatible with PostgreSQL? My Gemfile is running gem 'pg'
now instead of gem SQlite3
.
class CreatePosts < ActiveRecord::Migration[5.1]
def change
create_table :posts do |t|
t.string :title
t.string :summary
t.string :thumbnail_link
t.text :body
t.integer :blog_category_id
t.timestamps
end
end
end
Does rails automatically convert everything when I run the migration? Thanks in advance!
Yes, you can, just go ahead and run rails db:migrate
on your local machine, but if it's already on Heroku run heroku run rails db:migrate
. remember to change your database settings in config/database.yml
before doing so. Cheers!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.