1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-06-21 00:14:04 +00:00
Commit graph

33 commits

Author SHA1 Message Date
github-actions[bot]
b743720c7c Fix code style (php-cs-fixer) 2026-06-10 05:57:06 +00:00
lukinovec
028b985e54 Improve annotations
Add newline after @var tenant annotation, make usage of`DB::getDatabaseName clearer.
2026-06-10 07:56:30 +02:00
0fdc59dc5d
comment grammar 2026-06-09 16:11:16 -07:00
lukinovec
93f77a5881 Fix PHPStan error 2026-06-09 10:00:28 +02:00
lukinovec
540e3635e2 Improve hardening
Make hardening work correctly even for named SQLite DBs, also make the related test test named SQLite DBs instead of just MySQL (the SQLite dataset fails when the DatabaseTenancyBootstrapper changes get reverted).
2026-06-09 09:56:02 +02:00
github-actions[bot]
7972da5475 Fix code style (php-cs-fixer) 2026-06-09 07:03:00 +00:00
lukinovec
565bc41bf3 Use a more specific central db check in the hardening feature
Instead of just checking the presence of the tenants table on the current connection to determine if the table is/isn't tenant, check the current database's name, and if it's the central DB name, throw the runtime exception.
2026-06-09 09:02:31 +02:00
13e32dd6ab
update docblock on $harden 2026-06-08 15:49:39 -07:00
lukinovec
b7045c52d8 Rename harden() to verifyTenantCanUseDatabase() 2026-06-08 10:18:51 +02:00
lukinovec
42a2c8efd9 Improve $harden annotation 2026-06-08 10:03:07 +02:00
lukinovec
b4244be658 Determine data column and internal prefix dynamically instead of hardcoding in harden() 2026-06-08 10:02:49 +02:00
lukinovec
6ed9975e85 Catch broader range of exceptions (harden() in DB bootstrapper) 2026-05-04 12:14:39 +02:00
github-actions[bot]
fec170ada9 Fix code style (php-cs-fixer) 2026-05-04 09:55:13 +00:00
lukinovec
2b3466f951 Check the current DB name instead of configured one in harden() 2026-05-04 11:48:55 +02:00
lukinovec
7660ddd3ab Improve readability of harden() call 2026-05-01 14:43:27 +02:00
lukinovec
52f6857302 If harden throws an exception, revert connection back to central 2026-05-01 12:08:02 +02:00
github-actions[bot]
fc6a931a32 Fix code style (php-cs-fixer) 2026-05-01 09:50:30 +00:00
lukinovec
665404e7fa Add DatabaseTenancyBootstrapper::$harden
Since It's possible to update tenant's db_name to the central DB or the DB of another tenant. Setting $harden to true prevents tenants from connecting to the wrong databases.
2026-05-01 11:44:56 +02:00
a0a9b85982 Refactor DatabaseConfig, minor DB manager improvements, resolve todos
Notable changes:
- CreateUserWithRLSPolicies: Clarify why we're creating a custom
  DatabaseConfing instance
- HasDatabase: Clarify why we're ignoring tenancy_db_connection
- DatabaseConfig: General refactor, clarify the role of the host conn
- SQLiteDatabaseManager: Handle trailing DIRECTORY_SEPARATOR
  in static::$path
- DisallowSqliteAttach: Don't throw any exceptions, just silently fail
  since the class isn't 100% portable
- Clean up todos that are no longer relevant
- Clean up dead code or comments in some database managers
2025-10-13 16:01:34 +02:00
33e4a8e4e2 Remove and recategorize todos 2025-08-31 16:57:52 +02:00
83b1ae1aea change default cookie name, add todos 2024-04-15 03:11:11 +02:00
Samuel Štancl
2d500f9780
Fix #1112 - throw an exception if DATABASE_URL is set (#9)
* fix #1112 - throw an exception when DATABASE_URL is defined, minor test changes

* Fix code style (php-cs-fixer)

* fix typo

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2023-08-18 20:21:00 +02:00
lukinovec
342c67fe02
Add skip-failing option to the Migrate command (#945)
* Add and test Migrate command's skip-failing option

* Improve naming

* Move migration event dispatching inside try block

* Change test name

* Fix skip-failing test

* Use QueryException instead of Exception

* Correct TenantDatabaseDoesNotExistException import

* Correct test

* Check for the the testing env in DB bootstrapper

* Correct the Migrate command

* Fix code style (php-cs-fixer)

* add docs todo

* Add QueryException to the Migrat command try/catch

* Return status codes in Migrate

* Fix code style (php-cs-fixer)

* Add test for not stopping tenants:migrate after the first failure

* Update Migrate command

* Fix code style (php-cs-fixer)

* Fix code style (php-cs-fixer)

* Use `getTenants()`

* Use withtenantDatabases where needed

* Add withTenantDatabases to test

---------

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2023-02-01 06:55:26 +01:00
Samuel Štancl
a94227a19c get down to 59 phpstan errors 2022-09-29 22:20:55 +02:00
Samuel Štancl
40bf28c7d0 general refactor, move more classes under Database namespace 2022-08-27 03:17:16 +02:00
Samuel Štancl
73a4a3018c Improve queue tenancy 2021-12-31 18:10:03 +01:00
Samuel Štancl
405a137ca1 Better solution for tenant DB exception 2020-06-29 12:18:03 +02:00
Samuel Štancl
41aead5da2 Revert "Get rid of TenantDatabaseDoesNotExist exception"
This reverts commit fe52a3c4ea.
2020-06-29 12:14:58 +02:00
stancl
9ed46bbc35 Apply fixes from StyleCI 2020-06-29 07:59:36 +00:00
Samuel Štancl
fe52a3c4ea Get rid of TenantDatabaseDoesNotExist exception 2020-06-29 09:58:37 +02:00
Samuel Štancl
579779b88b Move DatabaseManager 2020-05-30 15:38:29 +02:00
stancl
6955512a6b Apply fixes from StyleCI 2020-05-22 09:01:31 +00:00
Samuel Štancl
1a8d150f2c Change bootstrappers namespace 2020-05-13 18:19:59 +02:00
Renamed from src/TenancyBootstrappers/DatabaseTenancyBootstrapper.php (Browse further)