Heroku CRUD #101
Tags: github, heroku, crud, deployment
Published: 2021-11-03 18:24:47

> **BE NOTICED** : This article is Windows Git users oriented !

---
### Prereqs :

- I do consider you have installed CLI globally [link to installation instructed](https://devcenter.heroku.com/articles/git#prerequisites-install-git-and-the-heroku-cli)
- `heroku login` is done  

> **NOTE** : We will ignore file tracking for Git in this article !

---

### Create & Status

As you probably guess, today was my first day into Heroku , so I will recap what I've learned , which was nearly the terminal CRUD basics on Git for Heroku (check for ready-to-go refs at very end of this article as well – *that may save some time of your day surfing for instructions to follow*)

For the start Heroku asks us to initiate our Heroku app repo with specific signature of :

```diff
heroku create # creates a new empty application on Heroku, along with an associated empty Git repository.
```

For the sake of simplicity I will copy-paste some of info from Heroku officials ; Whenever we init with command of `heroku create` we should get sth like :

```diff
Creating app... done, ⬢ thawing-inlet-61413
https://thawing-inlet-61413.herokuapp.com/ | https://git.heroku.com/thawing-inlet-61413.git
```

> Explanation: one url is for app deployment | one for heroku-based repo
The later one also would match if `git remote -v` invoked , i.e.:

```diff
heroku https://git.heroku.com/thawing-inlet-61413.git (fetch)
heroku https://git.heroku.com/thawing-inlet-61413.git (push)
```

Let's say we made it , we double-checked if it really existed on `https://dashboard.heroku.com/apps` we should see some dummy name of heroku-based such as corresponding `thawing-inlet-61413` as a part of URI (URL)

---

Now imagine you decided to append your list with **another-crud-app** which let it be our next `heroku create another-crud-app` – this way we could add some meaningful name within next init of heroku repository . We double checked our dashboard as last time , we probably saw something like so :

```diff
Creating app... done, ⬢ another-crud-app
https://another-crud-app.herokuapp.com/ | https://git.heroku.com/another-crud-app.git
```

We probably ask ourselves : "Okay currently we made with two apps , even tho it could be more of 'em . How should I list 'em all ?" – Very simple , just do the following command on terminal :

```diff
heroku apps # this should print our list of two apps already created (see below)
```

<u>App list created</u> :

- thawing-inlet-61413
- another-crud-app

Nevertheless we already created two apps , command of `heroku info` still confirms we are are set on the former (old) repo of :

```diff
=== thawing-inlet-61413
Auto Cert Mgmt: false
Dynos:
Git URL:        https://git.heroku.com/thawing-inlet-61413.git
...
Web URL:        https://thawing-inlet-61413.herokuapp.com/
```

This was actually a tricky part I wanted you to pay most of attention at of . We all know Heroku is strongly related to Git version control system , where as Git strongly related to GitHub . Heroku integrates with GitHub to make it easy to deploy code living on GitHub to apps running on Heroku , those are two different platforms (if I could express that way – "platforms") tho . What I am trying to say here , is that both shares similar approach (in layman's terms – vibe) . This means that if you created one Heroku repo for your app and after created the next one and the next one : **every time you create next repo for your app you need to switch between repos manually** – in order to do so use the following signature :

```diff
heroku git:remote -a another-crud-app # equivalent to --add=another-crud-app
```

Now we should completely be set on recently created app for both : Heroku deployment and Heroku git-based repo . Double checked with the command of `heroku info` we should see the following :

```diff
=== another-crud-app
Auto Cert Mgmt: false
...
```

---

### Delete & Status

We can delete desired Heroku app exploiting following command :

```diff
heroku destroy -a another-crud-app -c another-crud-app # equivalent to --confirm=another-crud-app
```

[Complete **destroy** command reference](https://devcenter.heroku.com/articles/heroku-cli-commands#heroku-apps-destroy)

> NOTE : deleting repo with destroy command also requires mandatory manual reset of remote

If `heroku info` invoked this would yield pretty much like that :

```diff
No app specified.
 !    USAGE: heroku info my-app 
```

Of course we could do the following as `heroku info thawing-inlet-61413` which would support us with info , but you should not buy into 'cause `git remote -v` would yield you nothing . As mentioned per NOTE above – **we must explicitly reset to the app of choice** required as for an example :

```diff
heroku git:remote -a thawing-inlet-61413 # equivalent to --add=thawing-inlet-61413
```

This time it's enough of `heroku info` without providing name and `git remote -v` should support you with the following info as expected :

```diff
heroku  https://git.heroku.com/thawing-inlet-61413.git (fetch)
heroku  https://git.heroku.com/thawing-inlet-61413.git (push)
```

We got back as we'd been before creating recent app of **another-crud-app**

---

<u>Ready-to-go refs</u> :

- [Deploying with Git](https://devcenter.heroku.com/articles/git#creating-a-heroku-remote) <br>
- [Heroku with Node.js](https://devcenter.heroku.com/articles/getting-started-with-nodejs?singlepage=true) <br>
- [Relation in between Git, GitHub & Heroku](https://stackoverflow.com/questions/18733888/whats-difference-between-heroku-and-github)

---

If any typos found and (or) suggestions could be made, please leave it in the comment section below . Thank you and see you in the next one !