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

1182 commits

Author SHA1 Message Date
PHP CS Fixer
d14eb8609b Fix code style (php-cs-fixer) 2023-04-26 16:10:57 +00:00
lukinovec
e169cf49fa Create and drop schema in tests 2023-04-26 18:10:19 +02:00
PHP CS Fixer
4eea9f1031 Fix code style (php-cs-fixer) 2023-04-26 13:34:54 +00:00
lukinovec
034c284303 wip 2023-04-26 15:34:27 +02:00
lukinovec
562d507482 Test if policies get created correctly using action 2023-04-26 15:25:50 +02:00
lukinovec
338d6f1151 Revert ci.yml changes 2023-04-26 15:09:12 +02:00
lukinovec
6496f77415 Update ci.yml 2023-04-26 15:07:14 +02:00
lukinovec
044406c917 Update ci.yml 2023-04-26 15:06:27 +02:00
lukinovec
8a7c78fd53 Change environment to env 2023-04-26 15:04:05 +02:00
lukinovec
b66a163393 Update ci.yml 2023-04-26 15:01:36 +02:00
lukinovec
e58efc5964 Use latest Postgres version in docker-compose 2023-04-26 15:01:20 +02:00
lukinovec
ab0e53b402 Update ci.yml 2023-04-26 14:22:08 +02:00
lukinovec
910da724e4 WIP 2023-04-26 14:02:18 +02:00
lukinovec
e15eb01c7f WIP 2023-04-26 13:58:52 +02:00
lukinovec
add92b99cc Fixing test WIP 2023-04-26 13:54:56 +02:00
lukinovec
fd254e6a45 Update ci.yml 2023-04-26 13:35:48 +02:00
lukinovec
800af2d818 Try fixing the CI issue 2023-04-26 13:11:37 +02:00
lukinovec
9226a1ec6c Fix syntax error 2023-04-26 12:48:04 +02:00
lukinovec
44acaadb6e Improve command for creating RLS policies 2023-04-26 12:43:45 +02:00
lukinovec
331df8e239 Update Postgres tests 2023-04-26 12:42:19 +02:00
lukinovec
4ceb7c82e1 Add test for creating RLS policies for tables 2023-04-25 18:00:44 +02:00
lukinovec
9f4079e774 Revert extra changes in docker-compose 2023-04-25 14:46:27 +02:00
lukinovec
aafb629bae Use env variables in docker-compose 2023-04-25 14:33:09 +02:00
lukinovec
f4b0f4cee6 Delete 'user' from Postgres CI 2023-04-25 14:29:05 +02:00
lukinovec
7f1f594809 Merge branch 'master' of github.com:archtechx/tenancy into add-postgres-rls-support 2023-04-25 14:25:01 +02:00
lukinovec
607ef15758 Revert ci.yml changes 2023-04-25 14:24:28 +02:00
lukinovec
18b47fb4d0 Change Postgres port 2023-04-25 14:20:55 +02:00
lukinovec
28f8e3854a Update dependencies 2023-04-25 14:13:26 +02:00
lukinovec
a22666ed2d Update ci.yml 2023-04-25 14:12:07 +02:00
lukinovec
6e9d6aa5f4 Fix env variables in docker-compose 2023-04-25 14:04:56 +02:00
lukinovec
e7736c8244 Use port 5432 2023-04-25 13:54:26 +02:00
lukinovec
55258e6411 Add Postgres port to ci.yml 2023-04-25 13:39:37 +02:00
lukinovec
b4238e5cf8 Use env variables in docker-compose 2023-04-25 13:31:27 +02:00
lukinovec
e4aeccb2b0 Make postgres work in tests 2023-04-25 12:33:56 +02:00
lukinovec
ae25e25715 Fix job & test 2023-04-25 12:33:29 +02:00
lukinovec
4eab27e1f0 Add Postgres to db connections and docker-compose 2023-04-24 17:04:09 +02:00
lukinovec
dd4013c998 Add Postgres tests 2023-04-24 16:58:31 +02:00
Abrar Ahmad
bd9bbe8b41
Cache prefix mode for separating tenant caches (#1014)
* cache prefix

* prefix cache bootstrapper and tests

* remove comment

* DI app

* cache prefix base from config

* Create PrefixCacheBootstrapperTest.php

* remove `null` check

* fix phpstan error

* Update PrefixCacheTenancyBootstrapper.php

* Update PrefixCacheBootstrapperTest.php

* add comments

* Update PrefixCacheTenancyBootstrapper.php

* Update PrefixCacheBootstrapperTest.php

* Update config.php

* test names grammar

* user `getTenantKey` method

* assert tenants' data is accessible using the prefix from the central context

* remove unused line

* use proper DI

* build prefix using original prefix

* fix prefix test according to prefix changes

* fix test

* CacheManager dependency injection test

* CacheService class as singleton

* introduce second tenant in test

* use Repository in service class DI

* Update CacheAction.php

* Rename CacheAction to CacheService

* Update prefix bootstrapper and test (`setStore()` in CacheManager and Repository needed)

* Add macro

* Fix code style (php-cs-fixer)

* Simplify cache store refreshing

* Make Tenancy override CacheManager

* Update CacheManager, add refreshStore()

* Fix code style (php-cs-fixer)

* Uncomment cache tagging

* Revert condition in CacheManager to avoid excessive nesting

* Move `Cache::macro()` to a slightly more appropriate place

* Fix code style (php-cs-fixer)

* Use better class for the macro

* Toggle cache tags

* Make CacheManager::$addTags default to `true`

* Add changes to PR to Laravel

* Fix code style (php-cs-fixer)

* Revert changes, add comment

* Add test

* Make `$cache` non-nullable

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

* Add and test `nonTenantCacheDrivers`

* Add nonTenantCacheDrivers check

* Test that the prefix stays the same

* Change nonTenantCacheDrivers to tenantCacheStores

* Remove redundant CacheManager extend() call

* Make 'redis' the only tenant cache store in beforeEach, test that tenantCacheStores works

* Remove unused import, change word

* Make CacheService a singleton in a test

* Update test name

* Remove group('prefix')

* Rename CacheManagerService

* Improve specific cache store in a service test

* Improve comment

* Improve tests

* Use my Laravel fork

* Fix code style (php-cs-fixer)

* Downgrade Laravel

* Upgrade Laravel

* Hint Repository implementation instead of contract

* Fix types

* Fix code style (php-cs-fixer)

* Fix test

* Use Laravel fork in ci.yml

* use dev-master before our changes are released in L10

* remove laravel fork from repositories

* use 10.x-dev instead of master

* remove L9 support

* 10.x-dev (fix conflict resolution)

* use the laravel version from the ci matrix for the phpstan job as well

* Revert "use the laravel version from the ci matrix for the phpstan job as well"

This reverts commit 5f3079d2ff.

* Test that non-default stores get prefixed too

* Use new Laravel release, remove L9 support

* Complete L9 support removal

* Specify 10.1.1 as the minimal Laravel version in ci.yml

* Use 10.x-dev

* Prefix all cache stores specified in `$tenantCacheStores`

* Update Laravel

* Use tmpfs in docker-compose

* Add customizing cache store prefixes

* Test cache prefixing customization

* Fix code style (php-cs-fixer)

* Update ci.yml

* Delete tmpfs from docker-compose.yml (there were no benefits)

* Use default prefix generator inline, delete the 'default' key logic

* Fix original prefix logic

* Update tests

* Delete CacheTenancyBootstrapper

* Reset static properties in afterEach

* Use `$this->config` instead of `config()`

* Disable cache tagging by default, add CacheTagBootstrapper

* Fix code style (php-cs-fixer)

* Rename bootstrapper

* Improve CacheManager

* Move logic from separate method to __call

* Make original prefixes customizable

* Add info in comment

* Add defaultPrefix property

* Use `$this->app` instead of `app()`

* Rename bootstrapper

* Fix code style (php-cs-fixer)

* Use a single original prefix

* Update prefix generator logic + tests

* Correct `$addTags` reset in a test

* Update cache tests so that both prefixing and tagging is covered

* Simplify cache tests

* Delete afterEach

* Small testing improvements

* Set `cache.default` in beforeEach

* Update cache prefixing and tests

* Add assertion

* Refactor assertion

* Refactor assertions

* Delete TTL from cache put calls

* Add re-initialization cache assertion

* Assert that cache is null from the beginning

* Merge the tenantCacheStores tests

* Fix formatting

* Improve test name

* Improve tests

* Add cache manager config key

* Fix code style (php-cs-fixer)

* Update defaulting test

* Add todo

* Update comments

* Extract duplicate assertions into a closure

* Update comment

* Add assertions + comment

* Delete redundant config put calls

* Use `tenancy.cache.manager` config instead of `Stancl\Tenancy\CacheManager`

* Change setting to assertion, add comment

* Inline variable & config key assignment

* Delete `cache.default` assertion

* Override cache manager only in CacheTagsBootstrapper

* Fix code style (php-cs-fixer)

* Prefix both drivers by default, add assertions for the second driver where missing

* Clean up global state (static properties) in before/afterEach

* Add docblock to tags bootstrapper

* Delete extra dependency

* Add `illuminate/support` dependency back

* Use `$addTags` approach again

* Fix code style (php-cs-fixer)

* Revert "Fix code style (php-cs-fixer)"

This reverts commit ea805fa231.

* Revert "Use `$addTags` approach again"

This reverts commit 8f5a4e4eb6.

* Add commented CacheTagsBootstrapper with info to the bootstrappers config

* Delete legacy bootstrapper from the bootstrappers config, add info to the bootstrapper's docblock

* Delete "?" from `tenant()?->getTenantKey()

* call generatePrefix() on $bootstrapper

* misc improvements

---------

Co-authored-by: lukinovec <lukinovec@gmail.com>
Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: Samuel Štancl <samuel.stancl@gmail.com>
2023-04-24 16:25:51 +02:00
lukinovec
39fe252ef6 Add comment 2023-04-24 13:21:23 +02:00
PHP CS Fixer
20cb3dc647 Fix code style (php-cs-fixer) 2023-04-24 11:20:26 +00:00
lukinovec
eae4d378f7 Swap try/catch for if statements 2023-04-24 13:20:02 +02:00
lukinovec
2d75f185b8 Use Schema::getAllTables() instead of the migration file names 2023-04-24 11:10:06 +02:00
lukinovec
91936bc5ab Fix PHPStan error 2023-04-21 15:36:00 +02:00
lukinovec
0bf464b80d Filter migration files in create RLS policies command 2023-04-21 15:32:08 +02:00
lukinovec
2fc14837ab Correct job dispatching in tenants:create-postgres-user 2023-04-21 14:41:23 +02:00
lukinovec
64d1333d37 Add CreatePostgresUserForTenants 2023-04-21 14:35:26 +02:00
lukinovec
54d0ca6a68 Register CreateRLSPoliciesForTenantTables in TSP 2023-04-21 11:30:45 +02:00
lukinovec
cde3d4dc36 Delete L9 from CI 2023-04-21 11:13:02 +02:00
lukinovec
eec993151e Merge branch 'master' of github.com:archtechx/tenancy into add-postgres-rls-support 2023-04-21 10:59:38 +02:00
lukinovec
934574fcb2 Update ci.yml to match master 2023-04-21 10:54:59 +02:00