Skip to content

Commit 187a912

Browse files
committed
include more default files and folders in release assets
1 parent 5357ed5 commit 187a912

File tree

4 files changed

+64
-3
lines changed

4 files changed

+64
-3
lines changed

.github/workflows/release.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,17 @@ jobs:
4545
needs: [build, build-aws]
4646
runs-on: ubuntu-latest
4747
steps:
48+
- uses: actions/checkout@v3
4849
- uses: actions/download-artifact@v3
4950
- run: |
51+
rm -rf sqlpage/templates/*.handlebars;
5052
chmod +x sqlpage*/sqlpage;
5153
mv 'sqlpage macos-latest/sqlpage' sqlpage.bin;
52-
tar --create --file sqlpage-macos.tgz --gzip sqlpage.bin;
54+
tar --create --file sqlpage-macos.tgz --gzip sqlpage.bin sqlpage/sqlpage.json sqlpage/migrations sqlpage/templates;
5355
mv 'sqlpage ubuntu-20.04/sqlpage' sqlpage.bin;
54-
tar --create --file sqlpage-linux.tgz --gzip sqlpage.bin
55-
cd 'sqlpage windows-latest' && zip -r sqlpage-windows.zip *.exe
56+
tar --create --file sqlpage-linux.tgz --gzip sqlpage.bin sqlpage/migrations sqlpage/templates;
57+
mv 'sqlpage windows-latest/sqlpage.exe' .
58+
zip -r sqlpage-windows.zip sqlpage.exe sqlpage/migrations sqlpage/templates;
5659
- name: Create Release
5760
id: create_release
5861
uses: softprops/action-gh-release@v1

sqlpage-linux.tgz

1.1 KB
Binary file not shown.

sqlpage/migrations/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# SQLPage migrations
2+
3+
SQLPage migrations are SQL scripts that you can use to create or update the database schema.
4+
They are entirely optional: you can use SQLPage without them, and manage the database schema yourself with other tools.
5+
6+
## Creating a migration
7+
8+
To create a migration, create a file in the `sqlpage/migrations` directory with the following name:
9+
10+
```
11+
<version>_<name>.sql
12+
```
13+
14+
Where `<version>` is a number that represents the version of the migration, and `<name>` is a name for the migration.
15+
For example, `001_initial.sql` or `002_add_users.sql`.
16+
17+
When you need to update the database schema, always create a **new** migration file with a new version number
18+
that is greater than the previous one.
19+
Use commands like `ALTER TABLE` to update the schema declaratively instead of modifying the existing `CREATE TABLE`
20+
statements.
21+
22+
If you try to edit an existing migration, SQLPage will not run it again, will detect
23+
24+
## Running migrations
25+
26+
Migrations that need to be applied are run automatically when SQLPage starts.
27+
You need to restart SQLPage each time you create a new migration.
28+
29+
## How does it work?
30+
31+
SQLPage keeps track of the migrations that have been applied in a table called `_sqlx_migrations`.
32+
This table is created automatically when SQLPage starts for the first time, if you create migration files.
33+
If you don't create any migration files, SQLPage will never touch the database schema on its own.
34+
35+
When SQLPage starts, it checks the `_sqlx_migrations` table to see which migrations have been applied.
36+
It checks the `sqlpage/migrations` directory to see which migrations are available.
37+
If the checksum of a migration file is different from the checksum of the migration that has been applied,
38+
SQLPage will return an error and refuse to start.
39+
If you end up in this situation, you can remove the `_sqlx_migrations` table: all your old migrations will be reapplied, and SQLPage will start again.

sqlpage/templates/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SQLPage component templates
2+
3+
SQLPage templates are handlebars[^1] files that are used to render the results of SQL queries.
4+
5+
[^1]: https://handlebarsjs.com/
6+
7+
## Default components
8+
9+
SQLPage comes with a set of default[^2] components that you can use without having to write any code.
10+
These are documented on https://sql.ophir.dev/components.sql
11+
12+
## Custom components
13+
14+
You can write your own component templates and place them in the `sqlpage/templates` directory.
15+
To override a default component, create a file with the same name as the default component.
16+
If you want to start from an existing component, you can copy it from the `sqlpage/templates` directory
17+
in the SQLPage source code[^2].
18+
19+
[^2]: A simple component to start from: https://github.com/lovasoa/SQLpage/blob/main/sqlpage/templates/code.handlebars

0 commit comments

Comments
 (0)