Posts

How to migrate Data for a Table from one DB to another DB through remote server? (Postgres , Mysql)

MySQL for whole DB  DB Backup:  mysqldump -u root -p [database_name] > dumpfilename.sql  DB  Restore:  mysql -u root -p [database_name] < dumpfilename.sql for a particular TABLE from a DB  Backup:  mysqldump -u root -p [database_name] [table_name] > dumpfilename.sql  Restore:  mysql -u root -p [database_name] < dumpfilename.sql PostgreSQL Here IP :192.168.1.36 Port :5433 User name : paras DB1 :kgp3_23apr15 DB2 :kgp6_23apr15 Create Back Up file for both Data Base . In Terminal. bishnu@bishnu:~$ /opt/PostgreSQL/9.0/bin/pg_dump -h 192.168.1.36 -p 5433 -U paras kgp3_23apr15 > kgp3_23apr15_24_bisnu.sql bishnu@bishnu:~$ /opt/PostgreSQL/9.0/bin/pg_dump -h 192.168.1.36 -p 5433 -U paras kgp6_23apr15 > kgp6_23apr15_24_bisnu.sql Back Up file name will generate like 'kgp3_23apr15_24_bisnu.sql' Back Up file name will generate like 'kgp6_23apr15_24_bisnu.sql' so that any time if we are doing any wrong migra...

Latest Rails Interview Question

What is callback in rails ? Callbacks are methods that get called at certain moments of an object's life cycle. With callbacks it is possible to write code that will run whenever an Active Record object is created, saved, updated, deleted, validated, or loaded from the database. What is the difference between after create and after save ? Ans: after_create  only works once - just after the record is first created. after_save  works every time you save the object - even if you're just updating it many years later So if you want to do this email operation only just the once (and then never again) then use  after_create . If you want to do it  every  time the object is saved, then do it in  after_save after_create() Is called after Base.save on new objects that haven‘t been saved yet (no record exists). after_save() Is called after Base.save (regardless of whether it‘s a create or update save)