Skip to content

Commit ed4fabf

Browse files
committed
Merge remote-tracking branch 'upstream/main' into effective-congruences
2 parents bb9caed + 942caa5 commit ed4fabf

175 files changed

Lines changed: 2110 additions & 1926 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# When cloning the repository, copy this file as .env
22
# For getting started, you don't need to change any values
33

4-
CATDAT_DB_URL=file:databases/catdat/catdat.db
5-
CATDAT_DB_AUTH_TOKEN=
6-
74
APP_DB_URL=file:databases/app/app.db
85
APP_DB_AUTH_TOKEN=
96

.github/workflows/_deploy-reusable.yaml

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,7 @@ on:
66
is_prod:
77
required: true
88
type: boolean
9-
skip_db:
10-
required: true
11-
type: boolean
129
secrets:
13-
CATDAT_DB_URL:
14-
required: true
15-
CATDAT_DB_AUTH_TOKEN:
16-
required: true
1710
APP_DB_URL:
1811
required: true
1912
APP_DB_AUTH_TOKEN:
@@ -62,30 +55,14 @@ jobs:
6255
- name: Install Dependencies
6356
run: pnpm i
6457

65-
- name: Generate SvelteKit config
66-
run: pnpm svelte-kit sync
67-
68-
- name: Create snapshot of local database as static asset
69-
env:
70-
CATDAT_DB_URL: file:databases/catdat/catdat.db
71-
APP_DB_URL: file:databases/app/app.db
72-
run: |
73-
pnpm db:update
74-
pnpm db:snapshot
75-
76-
- name: Update production database
77-
if: ${{ !inputs.skip_db }}
58+
- name: Build database
7859
env:
79-
CATDAT_DB_URL: ${{ secrets.CATDAT_DB_URL }}
80-
CATDAT_DB_AUTH_TOKEN: ${{ secrets.CATDAT_DB_AUTH_TOKEN }}
8160
APP_DB_URL: ${{ secrets.APP_DB_URL }}
8261
APP_DB_AUTH_TOKEN: ${{ secrets.APP_DB_AUTH_TOKEN }}
8362
run: pnpm db:update
8463

8564
- name: Build app
8665
env:
87-
CATDAT_DB_URL: ${{ secrets.CATDAT_DB_URL }}
88-
CATDAT_DB_AUTH_TOKEN: ${{ secrets.CATDAT_DB_AUTH_TOKEN }}
8966
APP_DB_URL: ${{ secrets.APP_DB_URL }}
9067
APP_DB_AUTH_TOKEN: ${{ secrets.APP_DB_AUTH_TOKEN }}
9168
GITHUB_PRIVATE_KEY: ${{ secrets._GITHUB_PRIVATE_KEY }}

.github/workflows/deploy-preview-skip-db.yaml

Lines changed: 0 additions & 26 deletions
This file was deleted.

.github/workflows/deploy-preview.yaml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,4 @@ jobs:
99
contents: write
1010
with:
1111
is_prod: false
12-
skip_db: false
13-
secrets:
14-
CATDAT_DB_URL: ${{ secrets.CATDAT_DB_PREVIEW_URL }}
15-
CATDAT_DB_AUTH_TOKEN: ${{ secrets.CATDAT_DB_PREVIEW_AUTH_TOKEN }}
16-
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
17-
NETLIFY_ACCESS_TOKEN: ${{ secrets.NETLIFY_ACCESS_TOKEN }}
18-
APP_DB_URL: ${{ secrets.APP_DB_URL }}
19-
APP_DB_AUTH_TOKEN: ${{ secrets.APP_DB_AUTH_TOKEN }}
20-
_GITHUB_PRIVATE_KEY: ${{ secrets._GITHUB_PRIVATE_KEY }}
21-
REDIS_URL: ${{ secrets.REDIS_URL }}
22-
ADMIN_PAGE_PASSWORD: ${{ secrets.ADMIN_PAGE_PASSWORD }}
23-
EMAIL_ADDRESS: ${{ secrets.EMAIL_ADDRESS }}
24-
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}
25-
ENABLE_EMAILS: ${{ secrets.ENABLE_EMAILS }}
26-
APPROVAL_EMAIL: ${{ secrets.APPROVAL_EMAIL }}
12+
secrets: inherit

.github/workflows/deploy-prod-skip-db.yaml

Lines changed: 0 additions & 26 deletions
This file was deleted.

.github/workflows/deploy-prod.yaml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,4 @@ jobs:
99
contents: write
1010
with:
1111
is_prod: true
12-
skip_db: false
13-
secrets:
14-
CATDAT_DB_URL: ${{ secrets.CATDAT_DB_URL }}
15-
CATDAT_DB_AUTH_TOKEN: ${{ secrets.CATDAT_DB_AUTH_TOKEN }}
16-
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
17-
NETLIFY_ACCESS_TOKEN: ${{ secrets.NETLIFY_ACCESS_TOKEN }}
18-
APP_DB_URL: ${{ secrets.APP_DB_URL }}
19-
APP_DB_AUTH_TOKEN: ${{ secrets.APP_DB_AUTH_TOKEN }}
20-
_GITHUB_PRIVATE_KEY: ${{ secrets._GITHUB_PRIVATE_KEY }}
21-
REDIS_URL: ${{ secrets.REDIS_URL }}
22-
ADMIN_PAGE_PASSWORD: ${{ secrets.ADMIN_PAGE_PASSWORD }}
23-
EMAIL_ADDRESS: ${{ secrets.EMAIL_ADDRESS }}
24-
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}
25-
ENABLE_EMAILS: ${{ secrets.ENABLE_EMAILS }}
26-
APPROVAL_EMAIL: ${{ secrets.APPROVAL_EMAIL }}
12+
secrets: inherit

.github/workflows/test.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,5 @@ jobs:
2929
- name: Install Dependencies
3030
run: pnpm i
3131

32-
- name: Generate SvelteKit config
33-
run: pnpm svelte-kit sync
34-
3532
- name: Update and Test database
36-
env:
37-
CATDAT_DB_URL: file:databases/catdat/catdat.db
38-
APP_DB_URL: file:databases/app/app.db
39-
run: pnpm db:update
33+
run: pnpm db:update:catdat

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ to continuously run this update when a file in the subfolder [/databases/catdat/
7373

7474
### Troubleshooting
7575

76-
- If the local database is corrupted, delete the `catdat.db` file and recreate it using `pnpm db:update`.
76+
- If the local database is corrupted, recreate it using `pnpm db:update`.
7777
- If the `pnpm db:update` command fails, examine the error message to determine the cause. It could be due to malformed SQL, a contradictory property, or a failing test in the `pnpm db:test` script (which also runs as part of the update command), as explained below.
7878

7979
### Tests for Data Quality
@@ -156,6 +156,7 @@ As a practical guideline, avoid introducing more than four properties (or four c
156156

157157
1. Use `\varnothing` to display the empty set, not `\emptyset`.
158158
2. Write `non-empty`, not `nonempty`. Same for `non-unital`, `non-expansive`, etc.
159+
3. For categories which are referenced multiple times, create a [LaTeX macro](/src/lib/server/macros.ts) for their notation.
159160

160161
### Responsible Use of AI
161162

DATABASE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ For functors there are similar tables, such as:
4242
- `functor_implications`
4343
- `functor_property_assignments`
4444

45-
## Migrations vs. Data
45+
## Schema vs. Data
4646

47-
Migrations update the database structure: tables, views, indexes, and triggers. They are defined in SQL files located in the subfolder [/databases/catdat/migrations](/databases/catdat/migrations/). The command `pnpm db:migrate` applies any new migrations.
47+
The schema defines the structure of the database: tables, views, indexes, and triggers. It is specified in several SQL files located in the subfolder [/databases/catdat/schema](/databases/catdat/schema/). The command `pnpm db:setup` deletes the old database file (if it exists) and creates a new one using this schema.
4848

49-
Database entries (categories, properties, implications, etc.) are defined via SQL files in the subfolder [/databases/catdat/data](/databases/catdat/data). The command `pnpm db:seed` replaces the current database by clearing all existing data and inserting the entries defined in these SQL files.
49+
Database entries (categories, properties, implications, etc.) are defined in SQL files located in the subfolder [/databases/catdat/data](/databases/catdat/data/). The command `pnpm db:seed` replaces the current contents of the database by clearing all existing data and inserting the entries defined in these SQL files.
5050

5151
## Derived Data
5252

@@ -60,7 +60,7 @@ The command `pnpm db:test` executes some tests and verifies that the data behave
6060

6161
## One command for everything
6262

63-
Use `pnpm db:update` to run all the commands in sequence: `pnpm db:migrate`, `pnpm db:seed`,`pnpm db:deduce`, and `pnpm db:test`.
63+
Use `pnpm db:update` to run all the commands in sequence: `pnpm db:setup`, `pnpm db:seed`,`pnpm db:deduce`, and `pnpm db:test`.
6464

6565
Use `pnpm db:watch` to run this command automatically every time a file in the subfolder [/databases/catdat/data](/databases/catdat/data) changes. This is useful in particular during development.
6666

DEPLOYMENT.md

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,31 @@
11
# Deployment
22

3-
This page is only relevant for the maintainer(s) of this project.
4-
5-
## Hosting
6-
7-
The application is deployed on [Netlify](https://netlify.com). The database is hosted on [Turso](https://turso.tech).
3+
This page is only relevant to the maintainer(s) of this project.
84

95
- [GitHub repository](https://github.com/ScriptRaccoon/catdat)
106
- [Netlify project](https://app.netlify.com/sites/catdat/overview)
117

128
## Prerendering
139

14-
Most pages are prerendered for performance reasons. This implies that the database is consumed at build time to generate static HTML pages. The only non-prerendered pages are the search and comparison pages, since they involve a dynamic list of properties and categories.
10+
Most pages are prerendered for performance reasons. This implies that the database is consumed at build time to generate static HTML pages. The only non-prerendered pages are the search and comparison pages, since they involve dynamic lists of properties and categories.
11+
12+
## Databases
1513

16-
## Preview Database
14+
The CatDat SQLite database `catdat.db` is deployed as a file alongside the web application to Netlify and is located at `/var/task/databases/catdat/catdat.db` after deployment. The file system on Netlify is ephemeral, so this only works because the database is read-only during the runtime of the application.
1715

18-
Since deployment requires running `pnpm db:update`, which temporarily clears all tables in the database, we maintain a separate remote database `catdat-preview` on Turso as a copy of the production database `catdat`. This prevents temporary disruptions and data inconsistencies in production.
16+
However, the SQLite database `app.db` (used for user submissions and page visits) requires writes and is hosted remotely on [Turso](https://turso.tech).
1917

2018
## Deployment Process
2119

2220
Follow these steps to deploy to production:
2321

24-
1. **Preview Deployment.** On [GitHub's actions page](https://github.com/ScriptRaccoon/CatDat/actions), manually trigger the preview pipeline [deploy-preview.yaml](.github/workflows/deploy-preview.yaml).
25-
26-
It updates the remote preview database (`catdat-preview`) via `pnpm db:update`, builds the application, and creates a [deployment preview](https://docs.netlify.com/deploy/deploy-types/deploy-previews/) on Netlify. The production database and application remain unchanged in this step.
27-
28-
2. **Promote to Production.** If the deployment preview looks correct, promote it to production in [Netlify's Deploys UI](https://app.netlify.com/projects/catdat/deploys).
29-
30-
The updated application goes live and uses the preview database.
22+
1. **Preview Deployment.** On [GitHub's Actions page](https://github.com/ScriptRaccoon/CatDat/actions), manually trigger the preview pipeline [deploy-preview.yaml](.github/workflows/deploy-preview.yaml).
3123

32-
3. **Production Deployment.** On [GitHub's actions page](https://github.com/ScriptRaccoon/CatDat/actions), manually trigger the pipeline [deploy-prod.yaml](.github/workflows/deploy-prod.yaml).
24+
It creates the database via `pnpm db:update`, builds the application, and creates a [deployment preview](https://docs.netlify.com/deploy/deploy-types/deploy-previews/) on Netlify. For testing purposes, this step can also be used on branches other than `main`.
3325

34-
This pipeline updates the remote production database (`catdat`) via `pnpm db:update` (hence, consolidates it with the preview database `catdat-preview`), builds the application, and deploys it on Netlify. The previous deployment preview is no longer live.
26+
2. **Production Deployment.** If the deployment preview looks correct, on [GitHub's Actions page](https://github.com/ScriptRaccoon/CatDat/actions), manually trigger the pipeline [deploy-prod.yaml](.github/workflows/deploy-prod.yaml).
3527

36-
In case only the application, not the database has been updated since the last production deployment, the pipeline [deploy-prod-skip-db](.github/workflows/deploy-prod-skip-db.yaml) can be used. The preview deployment is not required.
28+
This pipeline creates the database via `pnpm db:update`, builds the application, and deploys it on Netlify. The previous deployment preview is no longer live. Moreover, a tag is created on GitHub.
3729

3830
## Domains
3931

0 commit comments

Comments
 (0)