Open Jcloghesy opened 1 year ago
[ ] 3.1.1 Postgres Server START-> startpostgres
In WSL2, start PostgreSQL service prior to running PSQL to start the PostgreSQL server enter command into WSL2 command line interface:
[ ] 3.1.2 PostgreSQL Command line Shell START-> psql
psql is the PostgreSQL command line shell it allows us to interact with the database from our terminal (should see labber=#) as this is the default user (& password fyi)
\c [name]
('you are now connected to database "[name]" as user 'labber")
lightbnb=# \i migrations/01_schema.sql psql: migrations/01_schema.sql:5: NOTICE: table "users" does not exist, skipping DROP TABLE CREATE TABLE….
Ensure: Tables created / exist in database Enter \dt at the psql prompt.
Split database schema into separate files, one per table See db folder for pre-populated examples
Do not edit the layout.css file directly, it is auto-generated by layout.scss.
Split routes into their own resource-based file names, as demonstrated with users.js and widgets.js.
Use helper functions to run your SQL queries and clean up any data coming back from the database.
See db/queries for pre-populated examples.
Use the npm run db:reset command each time there is a change to the database schema or seeds.
It runs through each of the files, in order, and executes them against the database.
Note: you will lose all newly created (test) data each time this is run, since the schema files will tend to DROP the tables and recreate them.