1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 08:24:04 +00:00
Commit graph

70 commits

Author SHA1 Message Date
Samuel Štancl
c74a7b6fd4 remove debuggable trait, update larastan 2023-01-31 03:59:33 +01:00
Samuel Štancl
87c08cebc4 Merge branch 'master' of github.com:archtechx/tenancy 2023-01-06 02:48:40 +01:00
Samuel Štancl
48fc63fe02 switch to PHP 8.2 2023-01-06 02:38:31 +01:00
Samuel Štancl
a0256fd5f3 Merge branch 'master' of github.com:archtechx/tenancy 2023-01-04 03:27:04 +01:00
Samuel Štancl
32a128d657 lower required php version back to 8.1 2023-01-04 03:08:56 +01:00
Samuel Štancl
d0dd87ab07 bump PHP to 8.2, minor ci fixes 2023-01-04 02:43:10 +01:00
Samuel Štancl
5849089373
Add SessionTenancyBootstrapper (#2)
* Add SessionTenancyBootstrapper

* Fix code style (php-cs-fixer)

* add value to bootstrappers config

* tenant aware call test

* reproduce issue in tests

* fix logic for calling tenant run from central context, finish tests

* change laravel version back

* bump laravel to ^9.38

* add listener to create tenant DBs

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Abrar Ahmad <abrar.dev99@gmail.com>
2022-11-20 02:32:25 +01:00
Abrar Ahmad
99dd862b20
[4.x] [WIP] Add phpstan to CI (#928)
* add phpstan

* resolve phpstan issue from CI

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2022-11-08 13:47:24 +01:00
Samuel Štancl
0fd54bd685 Merge branch 'master' of github.com:archtechx/tenancy 2022-11-01 12:47:24 +01:00
Samuel Štancl
198f34f5e1
[4.x] Add pending tenants (modified #782) (#869)
* Add readied tenants

Add config for readied tenants
Add `create` and `clear` command
Add Readied scope and static functions
Add tests

* Fix initialize function name

* Add readied events

* Fix readied column cast

* Laravel 6 compatible

* Add readied scope tests

* Rename config from include_in_scope to include_in_queries

* Change terminology to pending

* Update CreatePendingTenants.php

* Laravel 6 compatible

* Update CreatePendingTenants.php

* runForMultiple can scope pending tenants

* Fix issues

* Code and comment style improvements

* Change 'tenant' to 'tenants' in command signature

* Fix code style (php-cs-fixer)

* Rename variables in CreatePendingTenants

* Remove withPending from runForMultiple

* Update tenants option trait

* Update command that use tenants

* Fix code style (php-cs-fixer)

* Improve getTenants condition

* Update config comments

* Minor config comment corrections

* Grammar fix

* Update comments and naming

* Correct comments

* Improve writing

* Remove pending tenant clearing time constraints

* Allow using only one time constraint for clearing the pending tenants

* phpunit to pest

* Fix code style (php-cs-fixer)

* Fix code style (php-cs-fixer)

* [4.x] Optionally delete storage after tenant deletion (#938)

* Add test for deleting storage after tenant deletion

* Save `storage_path()` in a variable after initializing tenant in test

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>

* Add DeleteTenantStorage listener

* Update test name

* Remove storage deletion config key

* Remove tenant storage deletion events

* Move tenant storage deletion to the DeletingTenant event

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>

* [4.x] Finish incomplete and missing tests (#947)

* complete test sqlite manager customize path

* complete test seed command works

* complete uniqe exists test

* Update SingleDatabaseTenancyTest.php

* refactor the ternary into if condition

* custom path

* simplify if condition

* random dir name

* Update SingleDatabaseTenancyTest.php

* Update CommandsTest.php

* prefix random DB name with custom_

Co-authored-by: Samuel Štancl <samuel@archte.ch>

* [4.x] Add batch tenancy queue bootstrapper (#874)

* exclude master from CI

* Add batch tenancy queue bootstrapper

* add test case

* skip tests for old versions

* variable docblocks

* use Laravel's connection getter and setter

* convert test to pest

* bottom space

* singleton regis in TestCase

* Update src/Bootstrappers/BatchTenancyBootstrapper.php

Co-authored-by: Samuel Štancl <samuel@archte.ch>

* convert batch class resolution to property level

* enabled BatchTenancyBootstrapper by default

* typehint DatabaseBatchRepository

* refactore name

* DI DB manager

* typehint

* Update config.php

* use initialize() twice without end()ing tenancy to assert that previousConnection logic works correctly

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
Co-authored-by: Abrar Ahmad <abrar.dev99@gmail.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>

* [4.x] Storage::url() support (modified #689) (#909)

* This adds support for tenancy aware  Storage::url() method

* Trigger CI build

* Fixed Link command for Laravel v6, added StorageLink Events, more StorageLink tests, added RemoveStorageSymlinks Job, added Storage Jobs to TenancyServiceProvider stub, renamed misleading config example.

* Fix typo

* Fix code style (php-cs-fixer)

* Update config comments

* Format code in Link command, make writing more concise

* Change "symLinks" to "symlinks"

* Refactor Link command

* Fix test name typo

* Test fetching files using the public URL

* Extract Link command logic into actions

* Fix code style (php-cs-fixer)

* Check if closure is null in CreateStorageSymlinksAction

* Stop using command terminology in CreateStorageSymlinksAction

* Separate the Storage::url() test cases

* Update url_override comments

* Remove afterLink closures, add types, move actions, add usage explanation to the symlink trait

* Fix code style (php-cs-fixer)

* Update public storage URL test

* Fix issue with using str()

* Improve url_override comment, add todos

* add todo comment

* fix docblock style

* Add link command tests back

* Add types to $tenants in the action handle() methods

* Fix typo, update variable name formatting

* Add tests for the symlink actions

* Change possibleTenantSymlinks not to prefix the paths twice while tenancy is initialized

* Fix code style (php-cs-fixer)

* Stop testing storage directory existence in symlink test

* Don't specify full namespace for Tenant model annotation

* Don't specify full namespace in ActionTest

* Remove "change to DI" todo

* Remove possibleTenantSymlinks return annotation

* Remove symlink-related jobs, instantiate and use actions

* Revert "Remove symlink-related jobs, instantiate and use actions"

This reverts commit 547440c887.

* Add a comment line about the possible tenant symlinks

* Correct storagePath and publicPath variables

* Revert "Correct storagePath and publicPath variables"

This reverts commit e3aa8e2086.

* add a todo

Co-authored-by: Martin Vlcek <martin@dontfreakout.eu>
Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>

* Use HasTenantOptions in Link

* Correct the tenant order in Run command

* Fix code style (php-cs-fixer)

* Fix formatting issue

* Add missing imports

* Fix code style (php-cs-fixer)

* Use HasTenantOptions instead of the old trait name in Up/Down commands

* Fix test name typo

* Remove redundant passing of $withPending to runForMultiple in TenantCollection's runForEach

* Make `with-pending` default to `config('tenancy.pending.include_in_queries')` in HasTenantOptions

* Make `createPending()` return the created tenant

* Fix code style (php-cs-fixer)

* Remove tenant ordering

* Fix code style (php-cs-fixer)

* Remove duplicate tenancy bootstrappers config setting

* Add and use getWithPendingOption method

* Fix code style (php-cs-fixer)

* Add optionNotPassedValue property

* Test using --with-pending and the include_in_queries config value

* Make with-pending VALUE_NONE

* use plural in test names

* fix test names

* add pullPendingTenantFromPool

* Add docblock type

* Import commands

* Fix code style (php-cs-fixer)

* Move pending tenant tests to a more appropriate file

* Delete queuetest from gitignore

* Delete queuetest file

* Add queuetest to gitignore

* Rename pullPendingTenant to pullPending and don't pass bool to that method

* Add a test that checks if pulling a pending tenant removes it from the pool

* bump stancl/virtualcolumn to ^1.3

* Update pending tenant pulling test

* Dynamically get columns for pending queries

* Dynamically get virtual column name in ClearPendingTenants

* Fix ClearPendingTenants bug

* Make test name more accurate

* Update test name

* add a todo

* Update include in queries test name

* Remove `Tenant::query()->delete()` from pending tenant check test

* Rename the pending tenant check test name

* Update HasPending.php

* fix all() call

* code style

* all() -> get()

* Remove redundant `Tenant::all()` call

Co-authored-by: j.stein <joristein@gmail.com>
Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Abrar Ahmad <abrar.dev99@gmail.com>
Co-authored-by: Riley19280 <rileyaven88@gmail.com>
Co-authored-by: Martin Vlcek <martin@dontfreakout.eu>
2022-10-31 12:14:44 +01:00
Samuel Štancl
ae8b01153a phpstan pro 2022-10-26 12:20:21 +02:00
lukinovec
080b271bb3
[4.x] Drop tenant databases on migrate:fresh (#971)
* Test that `migrate:fresh` deletes tenant databases

* Delete tenants on `migrate:fresh`

* Fix code style (php-cs-fixer)

* Add config key for dropping tenant databases on `migrate:fresh`

* Add MigrateFreshOverride

* Try to override `migrate:fresh` in TenancyServiceProvider

* Update `migrate:fresh` test

* Fix code style (php-cs-fixer)

* Drop tenant databases by default

* Change `migrate:fresh` test to test if the tenant DBs are dropped by default

* Override `migrate:fresh` by extending `FreshCommand` in TenancyServiceProvider

* Update MigrateFreshOverride

* Fix code style (php-cs-fixer)

* Fix commands test

* Simplify handle method

* Fix code style (php-cs-fixer)

* Don't drop tenant DBs on migrate:fresh by default

* Change command overriding

* Update migrate:fresh test

* always register MigrateFreshOverride

* misc

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2022-10-17 15:19:30 +02:00
Jori Stein
121370ea01
[4.x] Add command to bring the tenants up and down from maintenance and remove deprecated exception (#761)
* Add bring up from maintenance function

* Add up and down tenant maintenance commands

* Rename commands signatures

* Update TenancyServiceProvider.php

* Complying to Laravel maintenance code and parameters

* Update MaintenanceModeTest.php

* Add maintenance mode via commands test

* Update CheckTenantForMaintenanceMode.php

* Update MaintenanceModeTest.php

* Cookie bypass only for > Laravel 8

* minor formatting change, trigger CI

* clean

* Update MaintenanceModeTest.php

* Add comments for using the 'tenants' option in runForMultiple

* improve code

* php-cs-fixer

* fix php cs fixer config

* improve test logic

* remove version check since v4 will be L9+

Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2022-09-29 15:59:14 +02:00
Abrar Ahmad
3542b3f028
update spatie/ignition to support L9 (#930) 2022-08-30 15:21:19 +02:00
Samuel Štancl
8af354c20e get phpstan errors down from 252 to 189 2022-08-30 05:44:23 +02:00
Abrar Ahmad
fb8b9c1614
add phpstan (#926) 2022-08-29 20:55:33 +02:00
Samuel Štancl
40bf28c7d0 general refactor, move more classes under Database namespace 2022-08-27 03:17:16 +02:00
Samuel Štancl
2d7e9dfd89 Add 'composer coverage' 2022-08-26 22:29:40 +02:00
Samuel Štancl
5f41647a6b revert Tenancy changes, fix failing tests 2022-08-26 21:49:09 +02:00
Erik Gaal
ca2eefa30a
[WIP] Use a lighter Docker image, use it in CI (#793)
* Use action services and setup-php in workflow

* Fix codecov

* exclude master from CI

* Add space after 'up' in 'docker-compose up-d' (#900)

* Fix ArgumentCountError on the TenantAssetsController (#894)

* Fix ArgumentCount exception on the TenantAssetsController when no `$path` is provided

* CS

* CS

* Handle null case explicitly

* code style

Co-authored-by: Bram Wubs <bram@sibi.nl>
Co-authored-by: Samuel Štancl <samuel@archte.ch>

* Improve Dockerfile and use it in CI

* Update Dockerfile

* mssql CI health check

* cache key

* Update ci.yml

* Update ci.yml

* Update composer.json

* register dumcommand when L8

* Update ci.yml

* Update composer.json

* Update composer.json

* Update composer.json

* wip

* removed extensions config and php version from matrix

* introduce php-cs-fixer issue for testing

* Fix code style (php-cs-fixer)

* install composer in Docker and remove setup-php step

* added pcov for coverage

* on master branch

* composer test command

* tests above services

* Update ci.yml

* Revert "register dumcommand when L8"

This reverts commit f165fc58ba.

* removed composer cache dependencies

Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: Bram Wubs <megawubs@users.noreply.github.com>
Co-authored-by: Bram Wubs <bram@sibi.nl>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: Abrar Ahmad <abrar.dev99@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
2022-08-25 19:52:46 +02:00
Samuel Štancl
05f2a828a1 Better M1 DX 2022-07-22 22:29:56 +02:00
Samuel Štancl
2f3d4b9953 Allow pest plugin 2022-07-22 19:48:56 +02:00
Samuel Štancl
b47c5549ef
[4.x] Migrate tests to Pest (#884)
* Add Pest dependencies

* Add base Pest file

* Convert test cases

* Remove non-compound imports

* Adopt expectation API

* Optimize uses

* Shift cleanup

* phpunit -> pest

* Fix tests in PR #884 PHPUnit to Pest Converter  (#885)

* fixed tests, remove method duplications, restore necessary inner classes

* Update CommandsTest.php

* temporary checks run on `shift-64622` on branch.

* fixed `TestSeeder` class not resolved

* fixed messed up names

* removed `uses` from individual files and add it in `Pest`

* extract tests to helpers

* use pest dataset

* Update AutomaticModeTest.php

* newline

* todo convention

* resolve reviews

* added `// todo@tests`

* remove shift branch from CI workflow

Co-authored-by: Samuel Štancl <samuel@archte.ch>

* check if I have write permission

* Convert newly added tests to Pest

Co-authored-by: Shift <shift@laravelshift.com>
Co-authored-by: Abrar Ahmad <abrar.dev99@gmail.com>
2022-07-22 19:26:59 +02:00
Samuel Štancl
4aec6bfda2
add phpunit dependency 2022-06-28 21:47:33 +02:00
Samuel Štancl
eca7b336bc merge 3.x 2022-06-01 14:58:44 +02:00
Erik Gaal
79e3d53b06
[3.x] Compatibility with Laravel 9 (#802)
* Test on Laravel 9

* Don't extend final Kernel class

* Make FilesystemTenancyBootstrapper compatible with Flysystem v3

Co-authored-by: George <jiri.zizka@funfirst.cz>

* Update tenant maintenance mode te be in line with Laravel

* Exclude PHP 7.4 <> L9 combination from testing

* add root_override-related assertions

* getPrefix -> getPathPrefix

* handle / inconsistency in s3 prefix

* Refactor Storage facade changes

Co-authored-by: George <jiri.zizka@funfirst.cz>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2022-03-08 01:50:25 +01:00
Erik Gaal
9c79267e24
Fix .env loading in development (#799)
* Upgrade vlucas/phpdotenv to ^5.0

`Dotenv::create($paths)` was the syntax for releases before v4

* Remove vlucas/phpdotenv dependency and make it work with newer versions.
2022-02-14 14:31:01 +01:00
Samuel Štancl
5980c46449 wip 2021-12-30 19:46:48 +01:00
Samuel Štancl
9883219544 wip 2021-12-13 13:09:16 +01:00
Samuel Štancl
30a1f9102d
PHP 8 support (#542)
* PHP 8 support, test workflow syntax

* Try using a custom data structure in the workflow

* Try using matrix include

* Default PHP target

* single include

* fix composer package name

* [WIP] Try using dev-master for valuestore

* Update spatie/valuestore constraint to be stable
2020-11-30 17:30:42 +01:00
Andre Sayej
36aabb7883
First try at Laravel 8 (#491) 2020-09-08 21:11:56 +02:00
Samuel Štancl
f483d0b8cf Extract VirtualColumn package 2020-07-06 14:44:49 +02:00
Samuel Štancl
1833622170 Extract JobPipelines to a separate package 2020-05-15 18:26:08 +02:00
Samuel Štancl
b772590479 Private repo composer.json 2020-05-13 07:12:25 +02:00
Samuel Štancl
86a98b2bc8 Queue tests 2020-05-11 05:22:55 +02:00
Samuel Štancl
00bb0d06b3 Use real queues in JobPipelineTest 2020-05-11 04:33:55 +02:00
Samuel Štancl
bd9aad229b vague first draft of v3. TenantModelTest is passing 2020-05-08 04:37:43 +02:00
Samuel Štancl
5972364075
[3.x] Rename facades (#387)
* Remove Facade suffix from facades, fix #386

* Apply fixes from StyleCI

* Fix facade test
2020-05-03 17:59:35 +02:00
Samuel Štancl
4b46c65b2f
Support ramsey/uuid v3 & v4 2020-03-27 17:47:43 +01:00
Samuel Štancl
30bab68b6a
Laravel 7 support (#304)
* Laravel 7 support

* Remove language from travis.yml

* Fix travis.yml

* Consistent indentation in travis.yml

* Use dev-master for phpcov

* Cleanup

* switch up envs

* verify both laravel versions are used

* 6 -> 7

* Fix travis yml

* Use stable phpcov

* Different installation for Laravel 7

* Indentation

* Fix dockerfile

* Fix indentation

* Fix tests

* Remove fail() calls
2020-03-17 18:47:24 +01:00
Samuel Štancl
4e477b472f
Move ignition contracts to require 2019-11-23 15:17:51 +01:00
Mads Møller
b3cf499ebd add missing json extension (#217) 2019-11-06 18:02:51 +01:00
Samuel Štancl
97d47e33d0
Move facade/ignition-contracts to require-dev 2019-10-13 17:29:41 +02:00
Samuel Štancl
6cb7f27e6c
Replace webpatser/laravel-uuid with ramsey/uuid (#150) 2019-09-30 18:13:52 +02:00
Samuel Štancl
553b162930 Clean endTenancy() calls at the end of commands 2019-09-27 22:57:10 +02:00
Samuel Štancl
6b103cd2cb Model timestamps 2019-09-27 22:53:38 +02:00
Samuel Štancl
bd1c829520 TenantCouldNotBeIdentified ProvidesSolution 2019-09-23 11:54:38 +02:00
Samuel Štancl
50a77ee826 Fix some tests 2019-09-16 17:36:32 +02:00
Samuel Štancl
dabaff1338 Remove Tenant facade, move facades to Facades 2019-09-08 17:24:03 +02:00
Samuel Štancl
ab0a40a17e Laravel 6 2019-09-08 12:22:18 +02:00