Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- When install refuses over a same-named table, its message now names the fix that needs no
config file, `LARANAIL_SETTINGS_TABLE_PREFIX`, and the publish command for renaming single
tables; it used to point at config keys in a file that had not been published yet. The
installation guide says the same, warns that a partly published config replaces the whole
`tables` array, and lists `sync-definitions` after `migrate`.

## [0.1.0] - 2026-11-16

The first public release. `Added` describes the package; `Changed`, `Removed`, `Fixed` and
Expand Down
18 changes: 16 additions & 2 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The service provider registers itself through package discovery.
```bash
php artisan laranail::settings.install
php artisan migrate
php artisan laranail::settings.sync-definitions
```

Install publishes `config/laranail/settings.php` (tag `laranail::settings-config`) and the
Expand All @@ -50,6 +51,10 @@ package's one migration (tag `laranail::settings-migrations`,
reads the database first, so run the migrations before the first read; until then a read raises
`DriverUnavailable`.

`sync-definitions` copies the definitions declared in code and config into the definitions
table. Install runs it too, but on a fresh application the table does not exist yet, so install
says "Definitions were not synced" and the step above does it once the migration has run.

## Default categories

```bash
Expand All @@ -64,8 +69,17 @@ notifications, security) as system categories and changes nothing when run again
## When install refuses

Install refuses to publish anything when a table of the same name already exists and is not
this package's (a `settings` table of your own, say). Rename the package's tables with
`tables.prefix`, `stores.settings.table`, `tables.categories` or `tables.audit` and run it again.
this package's (a `settings` table of your own, say). Nothing is published yet, so the quickest
fix needs no config file: prefix every package table from `.env` and install again.

```bash
LARANAIL_SETTINGS_TABLE_PREFIX=laranail_
```

To rename single tables instead (`stores.settings.table`, `tables.categories`, `tables.audit`),
publish the config first with `php artisan vendor:publish --tag=laranail::settings-config`, edit
it, and install again. Keep the published file whole: the package's defaults are merged one
level deep, so a file holding only part of `tables` replaces the whole `tables` array.

## Without a database

Expand Down
2 changes: 1 addition & 1 deletion src/Providers/SettingsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ private static function refuseForeignTables(InstallCommand $command): void

if ($foreign !== []) {
throw new InvalidConfiguration(sprintf(
'These tables already exist and are not laranail/settings tables: %s. Set laranail.settings.tables.prefix (or stores.<name>.table, tables.categories, tables.audit) and install again.',
'These tables already exist and are not laranail/settings tables: %s. Nothing was published. Set LARANAIL_SETTINGS_TABLE_PREFIX (for example laranail_) in .env and install again; to rename single tables instead, publish the config with `php artisan vendor:publish --tag=laranail::settings-config`, set stores.<name>.table, tables.categories or tables.audit, and install again.',
implode(', ', $foreign),
));
}
Expand Down
8 changes: 8 additions & 0 deletions tests/Feature/Database/CommandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ function settingsMigrations(): array
expect(fn () => $this->artisan('laranail::settings.install')->run())->toThrow(InvalidConfiguration::class, DB::getDefaultConnection() . '.settings')
->and(settingsMigrations())->toBe([]);

// Nothing is published yet, so the message names the fix that needs no config file.
try {
$this->artisan('laranail::settings.install')->run();
} catch (InvalidConfiguration $refusal) {
expect($refusal->getMessage())->toContain('LARANAIL_SETTINGS_TABLE_PREFIX')
->toContain('--tag=laranail::settings-config');
}

// The package's own tables are not foreign: installing again over them is fine.
Schema::drop('settings');
useDatabase();
Expand Down
Loading