Guest User

Untitled

a guest
Sep 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. Knex Checklist
  2. NOTE: This is specifically for the Galvanize Knex Drills. If you haven't done so already, please visit the link below to fork and clone the Knex drill repo (galvanize-memory) before you begin
  3.  
  4. Galvanize Memory
  5.  
  6. If You Have Not Installed a Database Language
  7. 1: Install on Mac with Homebrew with one of the following database options
  8. brew install postgresql
  9. brew install mysql
  10. brew install mariadb
  11. 2: Start your database
  12. NOTE: Even if you have installed a database and done a million database drills, ALWAYS begin with the following command to check everything is up and running
  13.  
  14. brew services start postgresql
  15.  
  16. Above command should either successfully start or say already started
  17.  
  18. 3: Now the fun begins
  19. Create new directory outside the cloned Knex repo
  20. Copy repo drill files into new directory (using cp -r)
  21. git init
  22. express --git . (creates a git ignore. If you don't have this already type $ npm install -g express generator)
  23. you will only need to do npm install and can skip down to git commit
  24. npm start
  25. touch .gitignore
  26. npm init -y (this creates a package.json file)
  27. Create GitHub repo
  28. Link to GitHub repo
  29. Create Heroku Dyno
  30. Set Heroku buildpack to nodejs. this is under settings
  31. Link to Heroku Dyno. on deploy page copy paste the url at the bottom to my local repo.
  32. npm install - if dependencies aren't already there do the following.
  33. npm install pg
  34. npm install knex
  35. npm install cors
  36. npm install express
  37. npm install morgan
  38. git commit
  39. createdb 'dbname'
  40. psql 'dbname' (check database has been created)
  41. Add knex and start scripts to package.json
  42. knex init
  43. Update client and connection in knexfile.js for development client use client: 'pg', connection:'postgres://localhost:/[database name]'
  44. for production use (this is telling heroku what database to use in produciton client: 'pg', connection: process.env.DATABASE_URL
  45. knex migrate:make [choose a name]
  46. knex seed:make [choose a name] always put numbers in front of your seed because that will be the order they run. 00, 01, 02
  47. git commit
  48. in the knexfile.js write the schemas to create the table and it's colums. looks something like this return knex.schema.createTable('resolutions', (table) => { table.increments('id') table.date('dueDate').notNullable() table.text('resolution').notNullable() })
  49. $ knex migrate:latest - this will create the table and the columns.
  50. you can check and see if it worked by psql [dbname]
  51. \dt describe table
  52. \d [table name]
  53. leave the db with \q
  54. $ heroku addons:create heroku-postgresql (this will add postgresql to heroku app)
  55. git add commit push
  56. git push heroku master
  57. $ heroku run knex migrate:latest (this will run the migration on your deployed heroku app)
  58. $ heroku pg:psql (check to see the database tables on the deployed heroku app)
  59. add the seed data to the seed file
  60. knex seed:run (this seeds the local database
  61. psql [db name]
  62. talbe [table name]; (thes ; is important. this will make sure the table got seeded.)
  63. commit push and add to heroku.
  64. $ heroku run knex seed:run (this runs it on the deployed app)
  65. heroku pg:psql
  66. table [table name]; (see the seeded data on the deployed side.)
  67. write the routes and queries. test in postman.
  68. Now All Files Are Set Up To Begin Crushing Some Code
  69. Files to edit
  70. Sorry. The following checklist includes hints only
  71.  
  72. Edit database-connection.js with proper port
  73. Edit knex up/down in the migrations file
  74. Add data from drill README.md to the seed file
  75. © 2018 GitHub, Inc.
  76. Terms
  77. Privacy
  78. Security
  79. Status
  80. Help
  81. Contact GitHub
  82. Pricing
  83. API
  84. Training
  85. Blog
  86. About
Add Comment
Please, Sign In to add comment