mirror of
				https://github.com/Theodor-Springmann-Stiftung/musenalm.git
				synced 2025-10-31 02:05:32 +00:00 
			
		
		
		
	Pages now work
Default Pages Created & Updated Fields for every collection
This commit is contained in:
		
							
								
								
									
										40
									
								
								pages/migrations_einfuehrung/1739446527_einfuehrung.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								pages/migrations_einfuehrung/1739446527_einfuehrung.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| package migrations_einfuehrung | ||||
|  | ||||
| import ( | ||||
| 	"github.com/Theodor-Springmann-Stiftung/musenalm/dbmodels" | ||||
| 	"github.com/Theodor-Springmann-Stiftung/musenalm/pagemodels" | ||||
| 	"github.com/pocketbase/pocketbase/core" | ||||
| 	m "github.com/pocketbase/pocketbase/migrations" | ||||
| ) | ||||
|  | ||||
| var reihen_fields = core.NewFieldsList( | ||||
| 	pagemodels.EditorField(pagemodels.F_TEXT), | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	m.Register(func(app core.App) error { | ||||
| 		collection := pageCollection() | ||||
| 		if err := app.Save(collection); err != nil { | ||||
| 			app.Logger().Error("Failed to save collection:", "error", err, "collection", collection) | ||||
| 			return err | ||||
| 		} | ||||
| 		return nil | ||||
| 	}, func(app core.App) error { | ||||
| 		collection, err := app.FindCollectionByNameOrId( | ||||
| 			pagemodels.GeneratePageTableName(pagemodels.P_EINFUEHRUNG_NAME)) | ||||
| 		if err == nil && collection != nil { | ||||
| 			if err := app.Delete(collection); err != nil { | ||||
| 				app.Logger().Error("Failed to delete collection:", "error", err, "collection", collection) | ||||
| 				return err | ||||
| 			} | ||||
| 		} | ||||
| 		return nil | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| func pageCollection() *core.Collection { | ||||
| 	c := pagemodels.BasePageCollection(pagemodels.P_EINFUEHRUNG_NAME) | ||||
| 	c.Fields = append(c.Fields, reihen_fields...) | ||||
| 	dbmodels.SetBasicPublicRules(c) | ||||
| 	return c | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Simon Martens
					Simon Martens