Skip to content

v2.1.0 — Multi-tenant correctness, code generation fixes, and HTTP improvements#14

Merged
vedavith merged 6 commits into
mainfrom
2.1.0
Jun 27, 2026
Merged

v2.1.0 — Multi-tenant correctness, code generation fixes, and HTTP improvements#14
vedavith merged 6 commits into
mainfrom
2.1.0

Conversation

@vedavith

Copy link
Copy Markdown
Owner
  • bin/ef autoload path — Fixed resolution when installed as a Composer dependency (previously resolved inside the vendor package directory)
  • Console commands config path — All CLI commands now use getcwd() . '/config' instead of __DIR__-relative paths, so they work correctly from any project root
  • Table name pluralisation — Added Str::toTableName() with proper snake_case and English pluralisation (JournalEntryjournal_entries, not journalentrys). Used consistently across MigrationBuilder, EntityBuilder, and BaseRepository
  • Strategy-aware migrationsMigrationBuilder now accepts a $strategy parameter; tenant_id column is only emitted for the shared strategy. GenerateCommand and GenerateAllCommand read tenancy.strategy from config/application.yaml and pass it through
  • Tenant-scoped unique indexes — Unique indexes in shared strategy automatically prepend tenant_id as the first column, preventing cross-tenant unique constraint violations
  • FK columnsbelongsTo relations now emit INT NOT NULL FK columns (previously missing NOT NULL)
  • datetime type — Maps to DATETIME SQL type (previously fell through to TEXT)
  • BaseRepository::create() — Now returns the inserted row with id populated via lastInsertId()
  • MigrationRunner output — Accepts an injectable ?callable $output in the constructor; defaults to echo. Console commands inject $output->writeln() for Symfony Console formatting
  • TenantService::onboard() — Only calls TenantProvisioner::create() for database strategy; shared strategy registers the tenant row without provisioning a database
  • Request::capture() — Detects application/json Content-Type and parses php://input instead of relying on $_POST. Added json() helper method

vedavith added 4 commits June 19, 2026 12:14
…ation bugs

- bin/ef: fall back to project-root autoload.php when installed as a Composer
  package (the old path resolved inside the package and failed)
- Console commands: replace hardcoded __DIR__ config path with getcwd()/config
  so migrate/rollback/tenant:create resolve against the consuming project
- MigrationBuilder: always prepend id and tenant_id columns; add FK column
  definitions before CONSTRAINT lines; map datetime type to DATETIME; skip
  id/tenant_id/FK columns from the fields loop to prevent duplicates
- MigrationBuilderTest: update assertions and add coverage for new behaviour
…table output

- MigrationBuilder: always prepend id PK; conditionally add tenant_id based on
  strategy (shared/database); emit FK column definitions before CONSTRAINT;
  use Str::toTableName() for snake_case plural table names
- EntitySchema: remove isMultiTenant(); remove tenant_id injection from getFields();
  timestamps use datetime type; getPrimaryKey() always returns 'id'
- EntityGenerator: accept $strategy param; pass to MigrationBuilder; use
  Str::toTableName() for migration file basenames
- EntityBuilder: delegate pluralisation to Str::pluralize()
- Support/Str: new utility with toTableName() (snake_case + pluralize) and pluralize()
- BaseRepository: create() returns lastInsertId(); resolveTableName() uses Str::toTableName()
- MigrationRunner: injectable output callable; replaces all echo with ($this->output)()
- GenerateAllCommand/GenerateCommand: load strategy from config/application.yaml;
  pass to generator; simplify pkMap to array_fill_keys
- MigrateCommand/RollbackCommand/MigrateAllTenantsCommand: inject Symfony output
  callable into MigrationRunner
- Tests: remove dead isMultiTenant tests; add database strategy test; update
  OrderItem table name assertion; add lastInsertId assertions to create() tests
… provisioning guard

- MigrationBuilder: unique indexes in shared strategy now prepend tenant_id so
  the constraint is scoped per-tenant, not globally unique
- Request::capture(): detects application/json Content-Type and parses
  php://input instead of relying on $_POST; adds json() helper method
- TenantService::onboard(): only calls provisioner->create() for database
  strategy; shared strategy registers the tenant row without provisioning a DB
@codecov

codecov Bot commented Jun 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

vedavith added 2 commits June 27, 2026 12:38
- Request: test json() method and capture() JSON content-type branch
- EntitySchema: test getPrimaryKey()
- BaseRepository: test resolveTableName() via reflection
- MigrationBuilder: test default TEXT mapping for unknown field types
- ConsoleCommands: test strategy loading from application.yaml for both
  GenerateCommand and GenerateAllCommand
@vedavith vedavith merged commit 673326d into main Jun 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant