How to create with the postgres database
step 01 :: Basic Rails Command to create a rails application with basic api and database postgres.
rails new simple_rest_api --api --database=postgresql
In this we have add the postgres database and when we use the postgres database then we create and migrate this postgres in our application first.
step 02 : for this we create and migrate the database ::
default aur development mein change hoga production mein change nai hoga
In database.yml We do this ::
default: &default
adapter: postgresql
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
username: postgres
password: postgres
host: localhost
development:
<<: *default
database: new_data_dev
test:
<<: *default
database: new_data_test
Note : we have add these three options above dark and bold :: username and password and localhost
step 03 :: rake db:create and rake db:migrate
These are the command to create and migrate the postgres database in our rails application.
Important Point to remeber by rinku sir ::
pg gem lagana padhega
adapter mein bhi postgres likhna hoga
and default aur development mein change karna hoga bus production mein nai karna hai
Comments
Post a Comment