Is there a way to copy my local sqlite database table into my postgres database on production? I'm very new to Rails so any help is appreciated!
You need a tool to export data from Sqlite and import it to Postgres. You can use https://github.com/ricardochimal/taps.
Here is a tutorial for this: http://railscasts.com/episodes/342-migrating-to-postgresql
You can use taps
notice
I saw you have a question about heroku a few day before. Does this question involved with Heroku? If so, you should not use sqlite locally and postgres remotely.
Take a look at yaml_db for dumping and loading data. Easy to use.
Related
I did a homework on Rails using RubyMine.
I need to submit the homework with the database tables . But I can't access database tables file location, because I don't know under the which folder I created with migrate. I have migrated tables at the rubymine terminal
I used postgresql for database.
I will be so happy if you could help me. Thank you from now.
There is a schema.rb file that represents your database under db/ folder. So this is the answer for your first question.
The answer to second question is in order to deploy your code on a different computer, the third-party softwares need to be installed. In your scenario, this third-party is postgres as db server. To deploy your code, just type on your terminal rake db:setup. This command will create your database, run migrations and finally seed your database if db/seed.rb contains something. As a result, after rails s there should be some output.
It is worth to note that Rails is db agnostic framework. If you did not use postgres specific features then you would use mysql or sqlite on different computers/servers. But keep in mind that you should change the adapter from config/database.yml if you want to use another database.
Ödev sunumunda başarılar.
I just switched my whole app's (dev and test) databases to Postgres and got it working well. I did have a ton of information (users, posts, etc) on my local sqlite database that I would love to transfer over to my new PG local database. Is this even possible? Are there any resources y'all can point me to that can give me an idea of how to accomplish this? Thanks in advance!
The 'taps' gem can do it. Looks like there is an updated one called 'taps-taps.'
See: https://shellycloud.com/blog/2013/10/easy-database-migration-using-taps
So basically I am making a new sample application that will run using an external Postgres database and a model, both created by another programmer who has given me this project.
I am supposed to create a rails app that will implement the model and database in order to add some mapping functionality. The problem is that I truly do not know how to migrate an existing database using the "db_name.sqldump" file they provided me. I have installed psql, created a new rails app and added the "pg" gem, but I haven't been able to create a table with all the model information.
I am not sure if I am being clear but I truly am pretty much lost here with RoR. Any input would help.
Assuming you've a pg_dump file, import it from the command line using either of psql or pg_restore.
http://www.postgresql.org/docs/current/interactive/app-pgrestore.html
Follow this railscast by Ryan Bates - http://railscasts.com/episodes/342-migrating-to-postgresql
To convert your sqldump to a sqlite db, Follow these guides : -
script to convert mysql dump sql file into format that can be imported into sqlite3 db
http://code-n-fold.com/2011/11/28/convert-mysql-dump-to-sqlite-format/
I saw some of the tutorials on how to migrate from sqlite to postgresql, but it is either for mac or it is for a new/fresh app. What if I already have an App with data sqlite in it. I am using rails 3.2.2 and windows 7. Anyone knows which is the best way to migrate sqlite to postgresql? Thanks
erm, if in development ,u re using sqlite and maybe you have to deploy to heroku, then it is just changing the gem for database. But the data will be blank, if you want to total migrate with data, I guess you have to dump the data and load it in postgresql
I am using sqlite3 in development and mysql in production on a Rails 3.2 app.
I'd like to be able to backup the mysql, and also to create a sqlite copy of it for use in the development environment. Anyone know how to do this, or the preferred way to back up mysql at least?
I'm partial to this one, and use it to convert to/from MSSQL, sqlite and MySQL quite a lot:
https://github.com/unixmonkey/rails_db_convert_using_adapters
This may not be feasible if you have a large DB, but I am working with a rather small one (about 10MB).
(1) I back up all of my model classes into a .zip file using a rake task, and then
(2) have a button (with admin authentication) that runs another rake task to reload the data.
So I can backup the data in dev/prod mode, push my files to the other environment, and reload the data from backup (it's in .csv files, so it's DB-independent). This worked for me switching between sqlite3 and mysql2 (I am using Rails 4.0.1 if that's relevant).
I can post code if that would be helpful to people, but it's a little messy so I'll save the eyesore unless someone would find it helpful. I've found the .csv into .zip file backup to be a nice workaround for different SQL systems, if you're working on the order of megabytes.