mirror of https://github.com/usual2970/certimate
				
				
				
			
		
			
				
	
	
		
			44 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Go
		
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Go
		
	
	
package migrations
 | 
						|
 | 
						|
import (
 | 
						|
	"encoding/json"
 | 
						|
 | 
						|
	"github.com/pocketbase/dbx"
 | 
						|
	"github.com/pocketbase/pocketbase/daos"
 | 
						|
	m "github.com/pocketbase/pocketbase/migrations"
 | 
						|
)
 | 
						|
 | 
						|
func init() {
 | 
						|
	m.Register(func(db dbx.Builder) error {
 | 
						|
		dao := daos.New(db);
 | 
						|
 | 
						|
		collection, err := dao.FindCollectionByNameOrId("4yzbv8urny5ja1e")
 | 
						|
		if err != nil {
 | 
						|
			return err
 | 
						|
		}
 | 
						|
 | 
						|
		if err := json.Unmarshal([]byte(`[
 | 
						|
			"CREATE INDEX ` + "`" + `idx_wkoST0j` + "`" + ` ON ` + "`" + `access` + "`" + ` (` + "`" + `name` + "`" + `)"
 | 
						|
		]`), &collection.Indexes); err != nil {
 | 
						|
			return err
 | 
						|
		}
 | 
						|
 | 
						|
		return dao.SaveCollection(collection)
 | 
						|
	}, func(db dbx.Builder) error {
 | 
						|
		dao := daos.New(db);
 | 
						|
 | 
						|
		collection, err := dao.FindCollectionByNameOrId("4yzbv8urny5ja1e")
 | 
						|
		if err != nil {
 | 
						|
			return err
 | 
						|
		}
 | 
						|
 | 
						|
		if err := json.Unmarshal([]byte(`[
 | 
						|
			"CREATE UNIQUE INDEX ` + "`" + `idx_wkoST0j` + "`" + ` ON ` + "`" + `access` + "`" + ` (` + "`" + `name` + "`" + `)"
 | 
						|
		]`), &collection.Indexes); err != nil {
 | 
						|
			return err
 | 
						|
		}
 | 
						|
 | 
						|
		return dao.SaveCollection(collection)
 | 
						|
	})
 | 
						|
}
 |