You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Instructions for Mac users [here](https://stackoverflow.com/a/55692783/7426333)
30
28
31
29
### Database
32
30
@@ -35,64 +33,45 @@ With this project, community members can...
35
33
- Run local MYSQL instance
36
34
37
35
- For Mac, try [DBngin](https://dbngin.com/) for an easy way to get started
38
-
- Initialize your DB schema by running
36
+
- Initialize your DB:
39
37
40
38
```sh
41
-
# Switch to API directory
42
-
>cdapi
39
+
# Switch to remix directory
40
+
>cdremix
43
41
44
-
# Take the schema in `src/seed/init-db-schema.sql` and apply it to your local database
45
-
> make init-local-db-schema
46
-
```
42
+
# Make sure all dependencies are installed
43
+
> yarn install --frozen-lockfile
44
+
45
+
# Take the schema in `prisma/schema.prisma` and apply it to your local DB
46
+
> npx prisma db push
47
+
48
+
# Seed the database with some sample data
49
+
> npx prisma db seed
47
50
48
-
- If you already have a local MYSQL instance but the schema is out of date, you can run the same command above and it will refresh your schema. Note that any local data you had will be deleted.
51
+
# Open a browser tab to view DB data
52
+
> npx prisma studio
53
+
54
+
# If you want to completely reset your DB and wipe all the data
55
+
> npx prisma migrate reset
56
+
```
49
57
50
58
- Expose PlanetScale DB branch locally
51
59
- This project uses a service called [PlanetScale](https://planetscale.com/) which applies the Git branching model to databases.
52
60
- There is a `master` DB branch which always contains the most up-to-date production schema and can only be updated by a "deploy request" (essentially a pull request).
53
61
- When you create a new Git branch and push it up to GitHub, CI/CD will automatically create a matching PlanetScale branch of the same name.
54
-
- You can then expose that branch locally by running `cd api && make pscale-db`, and connect to it as if it were a local MYSQL DB.
62
+
- You can then expose that branch locally by running `pscale connect trad_archive [your-branch-name]`, and connect to it like a local MYSQL DB.
55
63
56
-
### API
64
+
### Run the App
57
65
58
66
```sh
59
-
#Switch to api directory
60
-
>cdapi
67
+
#Go to remix directory
68
+
>cdremix
61
69
62
70
# Install dependencies
63
71
> yarn install --frozen-lockfile
64
72
65
-
# Run the API via Serverless Offline, similar to how it runs in production
66
-
> make api
67
-
68
-
# Or, run the API via Express which is faster locally
69
-
> make api-express
70
-
```
71
-
72
-
### Web
73
-
74
-
```sh
75
-
# Switch to web directory
76
-
>cd web
77
-
78
-
# Install dependencies
79
-
> yarn install --frozen-lockfile
80
-
81
-
# Serve the website at http://localhost:3000
73
+
# Start the dev server
82
74
> yarn dev
83
-
```
84
-
85
-
### Updating DB Schema
86
-
87
-
```sh
88
-
# Switch to api directory
89
-
cd api
90
-
91
-
# Add the SQL commands you'd like to run in `src/migration.sql`
92
-
...
93
-
ALTER TABLE user ADD COLUMN test varchar(255);
94
-
...
95
75
96
-
# Apply the migration simultaneously to your local MYSQL DB and the PlanetScale DB branch. If the migration succeeds, it will then update `src/seed/init-db-schema.sql` with the new schema.
0 commit comments