Repository navigation
Replace the migration stubs with one migration; add seeds, models and tenancy - #7
Merged
Merged
Conversation
The boundary cases build "exactly 300 seconds ago" from one clock reading and the verifier reads the clock again; on a slow run (coverage under Xdebug) a second passes between the two and the 300-second case lands on 301.
…nancy One migration, database/migrations/create_laranail_settings_tables.php, replaces the four stubs. It creates categories, the optional definitions table, every recorded database store's values table (a store on its own connection gets that connection's categories and audit) and the audit table, in that order, and drops them in reverse. Table definitions stay inline in the migration. make-store writes one copy of it pinned to the new store and connection. DefaultCategoriesSeeder creates the seed.categories set as system categories through the settings API, registered with the host's db:seed with foreign keys still checked; idempotent by slug and off with seed.enabled. Eloquent models (Setting, SettingCategory, SettingDefinition, SettingAuditEntry) and factories follow the recorded shape for tests, seeding and admin screens; the engine stays on the query builder. Tenancy: tenancy.mode none, column or database, and a TenantDiscriminator with stancl/tenancy and spatie/laravel-multitenancy adapters detected with class_exists. Column mode adds a tenant column leading the unique keys and filters values, categories, the audit trail and the models on it. Preloaded records are kept per tenant in every mode. The schema-switch matrix gains the tenancy factor: 10 shapes for 177 pairs, 1,152 in the full product.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
database/migrations/create_laranail_settings_tables.phpcreates categories, the optional definitions table, every recorded database store's values table and the audit table, in that order, anddown()drops them in reverse. A store on its own connection gets that connection's categories and audit tables. Every schema switch still comes from the recorded schema file. Table definitions stay inline in the migration: no builder class.installpublishes it as before, and migrations published from the old stubs keep working.make-storewrites one file per store: a copy of the migration with$only(and, with--connection,$pinnedConnection) rewritten. It keeps the existing refusal of a store that already has a migration, the input validation, shape recording and the printed config entry.DefaultCategoriesSeeder(indatabase/seeders) is registered with the host'sdb:seedthrough package-tools, with foreign-key checks kept on. It creates general, appearance, localisation, mail, notifications and security as system categories, writing through the settings API as the system actor so the changes are audited. It is idempotent and configurable withseed.enabled,seed.storesandseed.categories.Setting,SettingCategory,SettingDefinitionandSettingAuditEntryfollow the recorded shape and tenancy. Their factories need no Faker. The engine stays on the query builder.tenancy.modetakesnone,columnordatabase.TenantDiscriminatorhas a null default and closure adapters for stancl/tenancy and spatie/laravel-multitenancy, both detected withclass_existsand listed undersuggestonly. Column mode adds atenantcolumn that leads the unique keys, and values, categories, the audit trail and the models are filtered on it. Preloaded records are kept per tenant in every mode. The switch matrix now covers 177 pairs with 10 shapes; the full product is 1,152.Testing
vendor/bin/pest: 447 passed. Coverage 96.9% (floor 90). PHPStan at max level: no errors. Rector and Pint are clean, andcomposer validate --strictpasses.down()that leaves the audit table, an identity index without the tenant.databasegroup).Follow-up (existing, not introduced here)
With
definitions.tableon, a store on a non-default connection reads definitions from its own connection, where that table does not exist.