added automigrate tests

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

No files matched your search

+8
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())