feat(scripts): support external file embedding
This commit is contained in:
@@ -45,6 +45,21 @@ migrations/
|
||||
- `1_001_test.txt` - Wrong extension
|
||||
- `readme.md` - Not a SQL file
|
||||
|
||||
## External File Embedding
|
||||
|
||||
SQL files can include external files with `-- @embed` directives. File paths are resolved relative to the SQL file being read.
|
||||
|
||||
```sql
|
||||
-- @embed: path=assets/message.txt var=:message mode=text
|
||||
-- @embed: path=assets/payload.bin var=:payload mode=base64
|
||||
INSERT INTO assets (message, payload)
|
||||
VALUES (:message, decode(:payload, 'base64')::bytea);
|
||||
```
|
||||
|
||||
- `mode=text` reads UTF-8 text and replaces the placeholder with an escaped SQL string literal.
|
||||
- `mode=base64` reads any bytes and replaces the placeholder with a base64 SQL string literal.
|
||||
- The placeholder must be named, for example `:message`, and must appear in the SQL body.
|
||||
|
||||
## Usage
|
||||
|
||||
### Basic Usage
|
||||
|
||||
Reference in New Issue
Block a user