Skip to content
This repository has been archived by the owner on Feb 6, 2025. It is now read-only.

Commit

Permalink
Add DB schema file and instructions for how to upgrade database file …
Browse files Browse the repository at this point in the history
…in release builds
  • Loading branch information
987123879113 committed Jun 9, 2024
1 parent 474c3d6 commit 351e298
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,29 @@ on:
branches: [ "main" ]

jobs:
tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: sqlc-dev/setup-sqlc@v4
with:
sqlc-version: '1.26.0'

- name: Set up Go 1.22
uses: actions/setup-go@v5
with:
go-version: '1.22.x'

- name: Check generated sqlc
run: sqlc diff

- name: Check Go tests
run: go test ./...


build:
needs: [tests]
runs-on: ubuntu-latest

strategy:
Expand Down Expand Up @@ -68,6 +90,8 @@ jobs:
cp config.yml dist
cp LICENSE dist
cp -r updates dist
cp README.dist.md dist/README.md
find . -type f -iname "schema.sql" -exec cat {} >> "dist/schema_for_db_migration.sql" \;
- name: Create dist archive
run: zip -r /tmp/${{ env.ARCHIVE_NAME }} .
Expand Down
15 changes: 15 additions & 0 deletions README.dist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
If the database schema changes at all in the server then you must modify your local server.db accordingly for it to work with the newer server version. For this server, [Atlas](https://atlasgo.io/) is used for managing the database. Follow [the setup instructions](https://atlasgo.io/getting-started) to install Atlas.

Please make sure to create a backup of your server.db before updating the database schema as this is a destructive process.
```bash
For Windows:
copy server.db server_backup.db

For Linux/MacOS:
cp server.db server_backup.db
```

With atlas installed, execute the following command to update your local server.db using the provided schema_for_db_migration.sql file:
```bash
atlas schema apply --auto-approve --url "sqlite3://server.db" --dev-url "sqlite3://server_temp.db" --to "file://schema_for_db_migration.sql"
```

0 comments on commit 351e298

Please sign in to comment.