Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chrisco/w13-express-knex-heroku
https://github.com/chrisco/w13-express-knex-heroku
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/chrisco/w13-express-knex-heroku
- Owner: chrisco
- Created: 2016-07-11T19:10:18.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-07-11T19:20:28.000Z (over 8 years ago)
- Last Synced: 2024-03-17T06:22:45.451Z (8 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Practice Making and Deploying Crud App
````
$ express --hbs --git list
$ cd list
$ npm i -S knex pg dotenv
$ atom .
$ knex init
$ git init
Add .env and nodemodules to .gitignore file
$ npm i
$ createdb listEdit knexfile.js
require('dotenv').config();module.exports = {
development: {
client: 'pg',
connection: 'postgres://localhost/list'
},production: {
client: 'pg',
connection: process.env.DATABASE_URL + "?ssl=true"
}
};Create and edit db/knex.js
var environment = process.env.NODE_ENV || 'development';
var config = require('../knexfile')[environment];
var knex = require('knex')(config);
module.exports = knex;Edit Route and View
[see files]Make Migration
$ knex migrate:make devEdit Migration
$ knex migrate:latestSeed DB
$ knex seed:make peopleRun Seeds
$ knex seed:runDeploy
$ heroku create // https://radiant-sea-70457.herokuapp.com/
$ heroku addons:create heroku-postgresql --app radiant-sea-70457
$ heroku pg --app radiant-sea-70457
$ heroku pg:psql --app radiant-sea-70457Get Database URL and Put in .env
$ heroku config // postgres://pylhthgvuxkedy:eTkdeJVtTczOigMzto1eAyf8RO@ec2-54-235-208-3.compute-1.amazonaws.com:5432/d28e6ad209jcnMigrate and the on Heroku
$ knex migrate:latest --env production // Must have DB URL in .env for this to work
$ knex seed:run --env productionGit Commit and Push to Heroku and Open
$ git push heroku master
$ heroku open
````