Go to Postico and click that refresh arrow. Do something on your site that would cause data to be entered or changed. Moment of truth… go to your project’s shiny new url. gitignore normally (should) excludes node_modules, they are being rebuilt from the versions listed in your package.json. Heroku builds your project from your file system and your package.json, so even though your. I was dubious that it would work, but it did. If you’re using connect-pg-simple, you will have to add in that extra script from the docs that loads a table from your node_modules: psql -h host -U username -d database -w password < node_modules/connect-pg-simple/table.sql If you need to seed your tables with data for your app to function, run the same bash script as above, but replace “schema.sql” with your seed file. If the schema file was copied correctly, you should now have some tables visible. Click ‘connect’, and now you can view your database the same way you can access your local ones. Give it whatever nickname you want, keep the port as 5432, and now go back to that “View Credentials” section on Heroku and copy the host, user, database and password into these fields. On the entry screen, click ‘new favorite.’ If you have Postico, let’s configure that now to make it easier to track our success. If all went correctly, you now have tables and columns in your database. I did this because heroku bash does not prevent wrapping text over the command prompt when entering in a long string, and it was getting hard to read. You can opt to leave off the -w flag and you will be prompted for your password after hitting enter. psql -h host -U username -d db -w password < schema.sql I’ll just tell you what to type, and remember that you’re replacing ‘host’, ‘username’, ‘db’ and ‘password’ from the values in that View Credentials tab, and therefore your script will look much longer than this one. Whether you want to type this directly into the command prompt or create a script is up to you. We’re about to create a bash script that loads your schema.sql into your heroku database. Take a look around, and then navigate to the folder that contains your schema.sql. Your normal (probably jazzed up) command prompt will disappear and be replaced with the old, familiar $. We’re going to open up a bash terminal INSIDE of our project directory on Heroku. Look for a Part 4 addendum to this series in the (hopefully) near future. I don’t have a solid enough grasp quite yet to explain them to other people. Warning - if you are deploying a large app or planning on making changes to your schema in the future, you may want to stop here and learn about migrations, as they are easier to set up from the get-go. You’re going to be copying and pasting from here to the command line (or a text editor) soon, so set your windows up for ease of making that happen. In the ‘Database Credentials’ section, click on ‘View Credentials.’ Here is everything you need to set up and seed your database. Heroku’s gentle colors and minimalist font are still helping, right? If you see a landing page, great! If not, go back to your command line and type in heroku logs, which are helpfully color-coded: Type heroku open in the command line and a browser window will open. If you get “build successful” near the end of the wall of text, your app might be ready, but any database functionality will still need to be configured. This takes longer than a regular git push because there is a build step happening. The next step is super easy: git push heroku master Make sure you’re on your local master branch and it is clean and updated. Navigate to the root folder of your project repository if you aren’t there already, and use this magic command, substituting ‘your-weird-appname’ with your new heroku app name: heroku git:remote -a your-weird-appnameĬongrats! In addition to your usual remote branch on Github, you now have a remote branch on Heroku. Next, let’s set up a git connection to Heroku. env file has not been deployed to Heroku. You will need to add your other process.env variables (like SESSION_SECRET) here, as the. You will see DATABASE_URL filled in for you as the first key, with your new database connection string as the value. On Heroku, click on the ‘settings’ tab of your main app page and then on ‘Reveal Config Vars’. Remember those process.env variables from Part 1? We’re about to see them in action now. Ignore the “clone the repository” links on that image, as we have no Heroku repository yet. I wish I could walk you through this, but I did this months ago and have forgotten. You can simply connect your app with Github, but Heroku Cli has a bunch of handy tools that I’m going to use shortly, so let’s install it. Soothing, muted colors to calm your nerves.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |