Home Keeping existing data
Reply: 0

Keeping existing data

user921 Published in May 21, 2018, 10:32 pm

I had to create another table to extract some columns I my_tables there are many columns but a couple needed to be extracted to be used elsewhere.

So the my_new_table exists, but It doesn't have the data that I had in the columns userand guest in my_tables... So I have to rollback my migration and insert some SQL I guess? to take the data from my_tables user & guest ? How to do this please ?

class CreateMyNewTables < ActiveRecord::Migration
  def change
    create_table :my_new_tables do |t|
      t.string :user
      t.string :guest
      t.references :my_tables, index: true
      t.timestamps null: false

      #how to keep the data I already have in Guest and User

    remove_column :my_tables, :guest
    remove_column :my_tables, :user

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301252 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO