@@ -183,4 +183,38 @@ This is perfectly fine, this is just Flask Migrate checking for a migration. If
Likewise, if you ran "RunUpgradeMigration" but cancelled before continuing with the autogenerated migration script created, you can ignore the output and continue; it'll take the HEAD of the migration scripts applied, and call the "upgrade" method, then move the HEAD to that script version.
#### (2) Check whether or not you "registered" the model
Whenever you add a new model you must also modify the upper package's `__init__.py` files to import it.
\ No newline at end of file
Whenever you add a new model you must also modify the upper package's `__init__.py` files to import it.
# Working with the CLI
This template comes with a CLI that is enabled when your environment is in the "dev" mode. It assumes all arguments provided on running "app.py" are CLI arguments.
If you haven't already configured a "second_db", you will need to configure one for the next tutorials.
## Tutorial: Inserting Rows
You can insert rows using raw SQL queries via PgAdmin, however you can also insert rows using the CLI.
1. Navigate to "cli_handler.py", let's see what commands are available to us.
2. CTRL + F: CLI Argument Names
3. This region contains all arguments you are allowed to specify, for example: `app.py action=insert-iris-class binding=second_db ...`.
4. The valid "binding" values are those associated with your databases, it'll allow the CLI to determine which db to operate on.
5. Now checkout the available "action" names => CTRL + F: ACTION handlers
6. Lets populate our "IrisClass" table.
7. Using the CLI type in: `app.py action=populate-iris-class binding=second_db`. After running this command you should see the table populated in PgAdmin.
8. Lets add a new "Iris Class" to the "IrisClass" table. You can inspect its associated model in: `/models/second_db_models/iris_class.py`. Use the CLI to do this. The new iris class should be called `My Lovel Iris`, and note that to specify strings with space-separation we need to wrap the value in double quotes.
`py app.py action=insert-iris-class "My Lovely Iris" binding=second_db`
NOTICE: the CLI assumes values not containing '=' are arguments for the "action" handler.
9. Lets add a new "Iris" to the "Iris" table. You can inspect its associated model in: `/models/second_db_models/iris.py`. Use the CLI to do this.