Can Node and Rails share database? - ruby-on-rails

I have a Rails app which is using Postgresql. I want to make a new Node + React Native app and I want to use the same database (usernames, passwords and other details will be shared).
I saw lots of sources which are explaining how to set up Postgresql on Node, but how do I set up an existing database? For the dev environment it is stored locally if I'm not mistaken.

You just need to use this package.
https://github.com/sequelize/sequelize
This is a connector for nodejs and postgresql.
But I suggest you do not use both of them handle database migration at the same time.
You can use rails to handle the migration. And just implement the database query in nodejs.

Related

How to use multiple databases for Rails server?

I have a Rails application which is using PostgreSQL database and a huge user base is expected. Is there a way to use multiple databases, may be one database for Read operations and other for Write operations.
Any suggestions/solution?
You can achieve it via database clustering. Master database and slave database. Try using amazon RDS or Heroku services.
Use database sharding. Try using Master and slave databases.
Octopus is a really useful gem for that. https://github.com/thiagopradi/octopus

Starting Rails app with NoSQL and using Postgresql during deploy or production

I would like to understand how I can start a rails app that is using NoSQL when I first make it and then when I deploy or have the project in production use Postgresql?
I'm really new to rails and have a project due in 4 days that requires me to have Postgresql once the app is deployed to Heroku.
Any information would be great, Thank you.
I truly Recommend you to use the same DB in development, testing and production environments. Otherwise you'll encounter many issues in terms of the schema file (generated by the migrations). It starts from simple strings length supported by PG or MySql (MySql limitations are bigger), and also for types like 'inet' in PG that should be converted to 'string' in MySql.
BTW- the inet type is created by Devise for 'user' (Which is the most popular gem for authentication) model! Even for that case you'll receive errors.
For a direct answer- you can simply change the database adapter in config/database.yml file.
But for my experience for some customers that explicitly asked for PG to MySql conversion (the opposite side, does not really matter), I would suggest using the same DB everywhere. Or else- dragons.

How to setup new Redshift database with Heroku/Rails 4 app

I have been using Heroku-postgres as my database for my rails 4 app deployed to Heroku.
I connect to the DB locally using pgAdmin3, and haven't had any issues.
Now, I want to switch my database to a amazon-redshift instance which has been spun up for me. All I have is a username, password, and the database host name. Where do I store this information within my Rails 4 app so that my app will use this DB instead of the current postgres DB?
I provided a similar answer here, but I would recommend using this adapter to connect:
https://github.com/fiksu/activerecord-redshift-adapter
This certainly works well for any ActiveRecord query you need to do, I'm using insert statements to update redshift tables rather than ActiveRecord create. Working on a full redshift adapter, hopefully to be released in the next few weeks.
Here's the answer I've given in the past with code examples about halfway down:
How can I build a front end for querying a Redshift database (hopefully with Rails)
Heroku will need to support Redshift as a database option for you, otherwise you'll need to spin up your own stack.
It might be worthwhile checking out AWS EBS service to do this.

Is it possible to share a common Neo4j db by two Rails apps, each using Neography?

While using the Neography gem to implement a Neo4j database on a Rails app, it so appears that the database is local to that particular Rails app's embedded Neo4j server. I wish to share a common Neo4j DB between two Rails apps, just the way you could do with a MySQL database through entries into database.yml. Is this impossible while using Neography? If so, what could be my possible alternatives which don't involve JRuby(i.e. using neo4j.rb).
Neography is a wrapper to query a neo4j server through the REST protocol. In that case, you should be able to query from anywhere you want, once you have started the server, even with a simple curl command.
You want especially to uncomment this line in conf/neo4j-server.properties if your apps are on 2 different servers :
org.neo4j.server.webserver.address=0.0.0.0
Make sure however to protect your database, you can read here how to : http://docs.neo4j.org/chunked/stable/security-server.html

Which database should be chosen in Heroku?

I want to migrate a database to Heroku. The old database is exported to some JSON files, but now I don't know how to select the database in Heroku.
My issue is:
The data is always increasing, so in the future, there will be a lot of data. Which database is available for this?
I can only get JSON files from my old database. Can it be imported into the Heroku database?
My users are mostly in America. The database in Heroku whether lead the user's access speed slowly or not?
My project is using Ruby on Rails.
What should I do?
First of all, Heroku provides PostgreSQL as the default database. It might be the following reasons for use it.
PostgreSQL is a powerful, open source object-relational database system.
Heroku Postgres is the SQL database service run by Heroku that is provisioned and managed as an add-on.
Heroku Postgres is accessible from any language with a PostgreSQL driver including all languages and frameworks supported by Heroku: Java, Ruby, Python, Scala, Play, Node.js and Clojure.
For more you can refer this http://www.postgresql.org/about/advantages/.
It's better that you specify the database you currently use for your application. If you give more information, I will update my answer.
But firstly, reading the article Moving a Rails App to Heroku will help you a lot with moving the application to Heroku.
Heroku has addons from another provider. The only database they provide is PostgreSQL which is very nice and suitable for many kind of applications. It's just brilliant.
Read the mentioned article above.
If you create your application in Heroku, it will be located in the USA by default. I don't know if Heroku optimizes to the location of your application and addons or not, but normally if you have something slow in your application, it's your fault, not Heroku's.
Yes! Heroku loves Ruby on Rails

Resources