mirror of
https://github.com/pocketbase/pocketbase.git
synced 2026-10-24 06:50:25 +02:00
added automigrate tests
This commit is contained in:
1 parent
c6f03cda43
commit
33539452de
4 files changed
+841
-81
No files matched your search
@@ -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())
|
||||
|
||||
Reference in new issue
Block a user