Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Tests

on:
push:
branches: [ main ]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [ '18', '20', '22', '24', 'latest' ]
name: Node ${{ matrix.node-version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
# Native accelerators (zlib-sync, erlpack, ...) are optionalDependencies and may
# fail to build on newer Node; that does not fail the install. sqlite3 is required
# for the migration tests and builds here.
- run: npm install
- run: npm run test:unit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
/node_modules/
/config/
src/functions/scnx-integration.js
instrument.js
/.vscode/
/.idea/
4 changes: 3 additions & 1 deletion developer-docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Start here if you want to add a new feature as a module:
- [**Database models**](./database-models.md) - Sequelize `Model.init` pattern, `models-dir`, accessing models from
events.
- [**Localization**](./localization.md) - adding strings to `locales/en.json` and using `localize()`.
- [**Nickname manager**](./nickname-manager.md) - the shared service for changing member nicknames without modules
fighting each other.

## Configuration schema

Expand All @@ -34,7 +36,7 @@ The string + embed format used in `allowEmbed` config fields. Canonical referenc

## Migration

- [**Migration**](./migration.md) - upgrading between major bot versions.
- [**Migration**](./migration.md) - writing database migrations so schema changes reach existing installs.

## Validation

Expand Down
19 changes: 7 additions & 12 deletions developer-docs/database-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,13 @@ All standard Sequelize methods are available: `findOne`, `findAll`, `findOrCreat

## Migrations

The bot calls `sequelize.sync()` at startup, which creates missing tables and adds missing columns automatically. **It
does not modify or remove existing columns.** If you change a column's type, rename it, or drop it, you have two
options:

1. **Manual migration.** Use Sequelize's [umzug](https://github.com/sequelize/umzug) or write SQL by hand. Drop the
bot's table or run `ALTER TABLE` against your database.
2. **Bump the table name.** For breaking schema changes, rename `tableName` (e.g. `welcomer_User_v2`). The old table
stays in place for safety; you migrate data on the side.

For non-trivial migrations across versions, the bot exposes `module.exports.migrationStart()` / `migrationEnd()` from
`main.js` - call these around long-running migration code so SIGTERM/SIGINT defers shutdown until the migration
finishes.
The bot calls `sequelize.sync()` at startup, which creates missing **tables**. **It does not add columns to existing
tables, nor modify or remove existing columns.** So whenever you add, rename, change, or drop a field on an existing
model, ship a migration alongside it so existing installs pick up the schema change.

Migrations are file-based and run automatically on boot by an [Umzug](https://github.com/sequelize/umzug)-based runner -
you drop a file into your module's `migrations/` directory and the runner discovers it, applies it once, tracks it, and
backs up the affected tables first. See [migration.md](./migration.md) for the full guide.

## Associations

Expand Down
Loading
Loading