Rebuilding Tutorial I, using the clone from Github

I typed the code from the tutorial all the way up to the (and not including) Authentication chapter, trying to help verify the Tutorial text and images. I caught a few typos and created a few PRs.

In order to save me any additional work I also pushed all code to my own Github repository. Then I cloned this Github repository to a different folder on my workstation and tried to build and run the app. To my surprise I got this error

 yarn rw dev
yarn run v1.22.5
$ c:\work\redwood\rw-debugging\node_modules\.bin\rw dev
  āˆš Generating the Prisma client...
$ c:\work\redwood\rw-debugging\node_modules\.bin\cross-env NODE_ENV=development yarn dev-server
$ c:\work\redwood\rw-debugging\node_modules\.bin\webpack-dev-server --config ../node_modules/@redwoodjs/core/config/webpack.development.js
$ c:\work\redwood\rw-debugging\node_modules\.bin\dev-server
api | Running at 'http://localhost:8911'
api | Watching files in 'c:\work\redwood\rw-debugging\api\src\functions'
web | i ļ½¢wdsļ½£: Project is running at http://localhost:8910/
web | i ļ½¢wdsļ½£: webpack output is served from /
web | i ļ½¢wdsļ½£: Content not from webpack is served from c:\work\redwood\rw-debugging\web
web | i ļ½¢wdsļ½£: 404s will fallback to /index.html
api | Done. Took 3676ms.
api | POST /graphql 200 160.989 ms - 660
api |
api | Error:
api | Invalid `prisma.post.findMany()` invocation:
api |
api |
api |   The table `main.Post` does not exist in the current database.
api |
api |
api | 1 cb
api |   c:\work\redwood\rw-debugging\node_modules\@prisma\client\runtime\index.js:79160
api |
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
api | cd "c:\work\redwood\rw-debugging\api" && yarn cross-env NODE_ENV=development yarn dev-server exited with code 1
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
web | cd "c:\work\redwood\rw-debugging\web" && yarn webpack-dev-server --config ../node_modules/@redwoodjs/core/config/webpack.development.js  exited with code 1
Done in 813.01s.

It seems that pushing a working RW app to Github and fetching it back (to a different location) results with a non-working app.

Anyone willing to bail me out here :face_with_raised_eyebrow:

It looks like the tables are missing. Can you try yarn rw prisma db push or yarn rw prisma migrate deploy and see if that makes a difference?

Do you mean the dev.db? I verified that the it exists in both original folder and the folder with the cloned copy of the app - and they are identical (using DB Browser for SQlite)

caused

Running Prisma CLI:
yarn prisma migrate deploy --preview-feature --schema "c:\work\redwood\rw-debugging\api\db\schema.prisma"

Prisma schema loaded from db\schema.prisma
Datasource "DS": SQLite database "dev.db" at "file:./dev.db"

1 migration found in prisma/migrations
Error: P3005

The database schema for `./dev.db` is not empty. Read more about how to baseline an existing production database: https://pris.ly/d/migrate-baseline

error Command failed with exit code 1.

ended without the error but did not help my issue

After you saved your migration (previous step from linked tutorial, specifically ā€œSaving Dataā€) using command yarn rw prisma migrate dev, you might need to make your first baseline as the error describes. Try;

yarn rw prisma migrate resolve --applied <the-last-migration-filename>

for example

yarn rw prisma migrate resolve --applied 20210316161829_my_lastest_migration

Documentation: Prisma Migrate | Database, Schema, SQL Migration Tool

Edit

Did you get the same error after restarting the dev server?

Thanks, @jeliasson - in addition to your suggestions I found this discussion - the issue is closed and if it contains the correct answer, I will try to revive it. It describes a case that ought to have caught David R as well as me). I will post the findings here.

No worries! That discussion seems to be related to RedwoodJS 0.8.2 and Prisma has changed quite a lot since then - both in terms of cli and migrations.

Need to try all these alternatives again, including the handling of the env variable that Rob Cameron suggested in that other issue I cited. Thanks, now I have a few things to try :smiley_cat:

1 Like

Hello, Johan (@jeliasson)

I am trying to do two tasks at once - learn RWJS and verify the Tutorial articleā€™s correctness. I could likely learn RWJS faster without trying to analyze every sentence and each screenshot, but RWJS is such a ā€œdream come trueā€ appearance that I can not resist helping to ensure that the RWJS documentation is at the same level of excellence (indeed, the typos and other mistakes I found so far are nearly trivial). As I go along with the Tutorial, I am also building ā€œits modelā€ - the redwoodblog application, which I plan to use as the model for my planned ā€œDebugging Redwood Applicationā€ project.

I almost managed to recreate the Authentcation section - when I completely missed the paragraph

Before we continue, make sure your app is fully committed and pushed to GitHub, GitLab, or Bitbucket. Weā€™re going to link Netlify directly to our git repo so that a simple push to main will re-deploy our site. If you havenā€™t worked on the Jamstack yet youā€™re in for a pleasant surprise!

Without having the app fully committed and pushed to GitHub I got all excited by the simplicity and elegance of deploying apps to Netlify, so I proceeded ahead, getting myself deeper and deeper in the hole, blaming all errors I kept getting as ā€œchanges in Netlifyā€ not described in the Tutorial (itā€™s always someone elseā€™s fault).

Now, I reverted a few commits and am going to do the Authentication section right


I am planning to propose that the Tutorial adds a short section on how to use Github as the ā€œUndoā€ tool, something I already discussed with @thedavid. I believe that such information would help a lot to newbies, who would like to be able to undo the consequences of running an involved generator, that changes many files in the appā€™s project.

I tried to make such undo manually (comparing the two consecutive versions of the code manually) and failed monumentally.

Finally, after months of wondering how is it possible that nobody addressed my seemingly simple issue (prisma.post.findMany(), best described as a sequence of steps:

  1. Follow the RWJS Tutorial up to Routing Params section

  2. ā€œStoreā€ this application to GitHub.

  3. Clone the app from Github to a new local folder

  4. Build the clone and run it

    • yarn install
    • yarn rw dev

I discovered that my impression (how is it possible that nobody addressed my seemingly simple issue) was false. At least one kind person (@jeliasson) explained it here and I failed to understand it.

The recently published final version of Redwood Tutorial App explains what did I miss trying to run the app from the clone - steps 4 and 5 below.

1. git clone https://github.com/redwoodjs/redwood-tutorial
2. cd redwood-tutorial
3. yarn install

4. yarn rw prisma migrate dev
5. yarn rw prisma db seed

6. yarn rw dev

This is also the first time I found the reason for the existence of the file seed.js

Again, thank you @jeliasson and apologies to @thedavid (for dragging you through long issues like How to restore an application from GitHub, together with the database?).

Youā€™re welcome @adriatic. Glad you got it working!