1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-11-25 23:52:32 +02:00

added automigrate tests

This commit is contained in:
Gani Georgiev
2022-11-28 19:59:17 +02:00
parent c6f03cda43
commit 33539452de
4 changed files with 841 additions and 81 deletions

View File

@@ -72,11 +72,19 @@ func Register(app core.App, rootCmd *cobra.Command, options *Options) error {
// watch for collection changes
if p.options.Automigrate {
// refresh the cache right after app bootstap
p.app.OnAfterBootstrap().Add(func(e *core.BootstrapEvent) error {
p.refreshCachedCollections()
return nil
})
// refresh the cache to ensure that it constains the latest changes
// when migrations are applied on server start
p.app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
p.refreshCachedCollections()
return nil
})
p.app.OnModelAfterCreate().Add(p.afterCollectionChange())
p.app.OnModelAfterUpdate().Add(p.afterCollectionChange())
p.app.OnModelAfterDelete().Add(p.afterCollectionChange())