Compare commits

...

10 Commits

23 changed files with 2186 additions and 0 deletions

View File

@ -1,6 +1,8 @@
package router
import (
"strconv"
"github.com/labstack/echo/v5"
"github.com/pocketbase/pocketbase/apis"
"github.com/pocketbase/pocketbase/core"
@ -51,6 +53,22 @@ func (r *RouterContainer) bootstrapFarmerSurveyRoute() {
return apis.NewBadRequestError("Failed to read request data", err)
}
budgetSplit, err := validatePercentage(requestData.CropsProtectionExpenditurePercentage, requestData.FertilizerExpenditurePercentage, requestData.SeedsExpenditurePercentage)
if err != nil {
return apis.NewBadRequestError("Could not validate budget split percentage", err)
}
if !budgetSplit {
return apis.NewNotFoundError("Budget split percentage should add up to 100% ", err)
}
fertilizerSplit, err := validatePercentage(requestData.SyntheticFertilizersExpenditurePercentage, requestData.NaturalFertilizersExpenditure)
if err != nil {
return apis.NewBadRequestError("Could not validate fertilizer split percentage", err)
}
if !fertilizerSplit {
return apis.NewNotFoundError("Fertilizer split percentage should add up to 100% ", err)
}
if err := r.PB.Dao().RunInTransaction(func(txDao *daos.Dao) error {
userRecord, err := r.PB.Dao().FindFirstRecordByData("users", "phone", requestData.Phone)
if err != nil {
@ -211,3 +229,15 @@ func (r *RouterContainer) bootstrapFarmerSurveyRoute() {
return nil
})
}
func validatePercentage(inputs ...string) (bool, error) {
sum := 0
for _, numStr := range inputs {
num, err := strconv.Atoi(numStr)
if err != nil {
return false, err
}
sum += num
}
return sum == 100, nil
}

View File

@ -0,0 +1,93 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("4f0a5b2wec6okxi")
if err != nil {
return err
}
// update
edit_evergrow_crops := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "5kxslfpx",
"name": "evergrow_crops",
"type": "select",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 12,
"values": [
"rice",
"coffee",
"tea",
"sugarcane",
"miraa",
"avocados",
"maize",
"potatoes",
"sorghum",
"other_fruits",
"other_vegetables",
"other_grains",
"dragonfruit"
]
}
}`), edit_evergrow_crops)
collection.Schema.AddField(edit_evergrow_crops)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("4f0a5b2wec6okxi")
if err != nil {
return err
}
// update
edit_evergrow_crops := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "5kxslfpx",
"name": "evergrow_crops",
"type": "select",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 12,
"values": [
"rice",
"coffee",
"tea",
"sugarcane",
"miraa",
"avocados",
"maize",
"potatoes",
"sorghum",
"other_fruits",
"other_vegetables",
"other_grains"
]
}
}`), edit_evergrow_crops)
collection.Schema.AddField(edit_evergrow_crops)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,93 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("uutt9wj7d5ejmhz")
if err != nil {
return err
}
// update
edit_planned_crops := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "p4n5v8yf",
"name": "planned_crops",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 12,
"values": [
"rice",
"coffee",
"tea",
"sugarcane",
"miraa",
"avocados",
"maize",
"potatoes",
"sorghum",
"other_fruits",
"other_vegetables",
"other_grains",
"dragonfruit"
]
}
}`), edit_planned_crops)
collection.Schema.AddField(edit_planned_crops)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("uutt9wj7d5ejmhz")
if err != nil {
return err
}
// update
edit_planned_crops := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "p4n5v8yf",
"name": "planned_crops",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 12,
"values": [
"rice",
"coffee",
"tea",
"sugarcane",
"miraa",
"avocados",
"maize",
"potatoes",
"sorghum",
"other_fruits",
"other_vegetables",
"other_grains"
]
}
}`), edit_planned_crops)
collection.Schema.AddField(edit_planned_crops)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,93 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("o7i7dkfc0x2bw22")
if err != nil {
return err
}
// update
edit_crops := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "ltb2rowr",
"name": "crops",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 12,
"values": [
"rice",
"coffee",
"tea",
"sugarcane",
"miraa",
"avocados",
"maize",
"potatoes",
"sorghum",
"other_fruits",
"other_vegetables",
"other_grains",
"dragonfruit"
]
}
}`), edit_crops)
collection.Schema.AddField(edit_crops)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("o7i7dkfc0x2bw22")
if err != nil {
return err
}
// update
edit_crops := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "ltb2rowr",
"name": "crops",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 12,
"values": [
"rice",
"coffee",
"tea",
"sugarcane",
"miraa",
"avocados",
"maize",
"potatoes",
"sorghum",
"other_fruits",
"other_vegetables",
"other_grains"
]
}
}`), edit_crops)
collection.Schema.AddField(edit_crops)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,93 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("5pbnsptw25ip6b1")
if err != nil {
return err
}
// update
edit_crop := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "gt06xc9v",
"name": "crop",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"rice",
"coffee",
"tea",
"sugarcane",
"miraa",
"avocados",
"maize",
"potatoes",
"sorghum",
"other_fruits",
"other_vegetables",
"other_grains",
"dragonfruit"
]
}
}`), edit_crop)
collection.Schema.AddField(edit_crop)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("5pbnsptw25ip6b1")
if err != nil {
return err
}
// update
edit_crop := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "gt06xc9v",
"name": "crop",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"rice",
"coffee",
"tea",
"sugarcane",
"miraa",
"avocados",
"maize",
"potatoes",
"sorghum",
"other_fruits",
"other_vegetables",
"other_grains"
]
}
}`), edit_crop)
collection.Schema.AddField(edit_crop)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,79 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("4f0a5b2wec6okxi")
if err != nil {
return err
}
// update
edit_purchase_channels := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "fl4s3aca",
"name": "purchase_channels",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 5,
"values": [
"manufacturers",
"distributors",
"resellers",
"farmers",
"other",
"ncpb"
]
}
}`), edit_purchase_channels)
collection.Schema.AddField(edit_purchase_channels)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("4f0a5b2wec6okxi")
if err != nil {
return err
}
// update
edit_purchase_channels := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "fl4s3aca",
"name": "purchase_channels",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 5,
"values": [
"manufacturers",
"distributors",
"resellers",
"farmers",
"other"
]
}
}`), edit_purchase_channels)
collection.Schema.AddField(edit_purchase_channels)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,90 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("hcgj54gqdujejom")
if err != nil {
return err
}
// update
edit_distributor_name := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "zadtcvlf",
"name": "distributor_name",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"maraba_investments",
"farmers_center",
"farmers_world",
"farmers_desk",
"mazao_na_afya",
"modez_agrovet",
"wakulima_supplies",
"volcano",
"makutano_agrovet",
"kipkomo_agrovet",
"pioneer",
"golden_agrovet",
"skynet_agrovet",
"mkulima_bora",
"beta_green",
"mwangaza_agrovet",
"prima_met_agrovet"
]
}
}`), edit_distributor_name)
collection.Schema.AddField(edit_distributor_name)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("hcgj54gqdujejom")
if err != nil {
return err
}
// update
edit_distributor_name := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "zadtcvlf",
"name": "distributor_name",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"maraba_investments",
"farmers_center",
"farmers_world",
"farmers_desk",
"mazao_na_afya"
]
}
}`), edit_distributor_name)
collection.Schema.AddField(edit_distributor_name)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,90 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("w7vsnhq55laqara")
if err != nil {
return err
}
// update
edit_distributor_name := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "rjvhxlwa",
"name": "distributor_name",
"type": "select",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"maraba_investments",
"farmers_center",
"farmers_world",
"farmers_desk",
"mazao_na_afya",
"modez_agrovet",
"wakulima_supplies",
"volcano",
"makutano_agrovet",
"kipkomo_agrovet",
"pioneer",
"golden_agrovet",
"skynet_agrovet",
"mkulima_bora",
"beta_green",
"mwangaza_agrovet",
"prima_met_agrovet"
]
}
}`), edit_distributor_name)
collection.Schema.AddField(edit_distributor_name)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("w7vsnhq55laqara")
if err != nil {
return err
}
// update
edit_distributor_name := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "rjvhxlwa",
"name": "distributor_name",
"type": "select",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"maraba_investments",
"farmers_center",
"farmers_world",
"farmers_desk",
"mazao_na_afya"
]
}
}`), edit_distributor_name)
collection.Schema.AddField(edit_distributor_name)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,85 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("uutt9wj7d5ejmhz")
if err != nil {
return err
}
// update
edit_county := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "murxdavm",
"name": "county",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"kirinyaga",
"muranga",
"nakuru",
"meru",
"uasin_gishu",
"kajiado",
"kericho",
"elgeyo_marakwet",
"kakamega",
"bungoma",
"nyandarua"
]
}
}`), edit_county)
collection.Schema.AddField(edit_county)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("uutt9wj7d5ejmhz")
if err != nil {
return err
}
// update
edit_county := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "murxdavm",
"name": "county",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"kirinyaga",
"muranga",
"nakuru",
"meru",
"uasin_gishu",
"kajiado"
]
}
}`), edit_county)
collection.Schema.AddField(edit_county)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,103 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("hcgj54gqdujejom")
if err != nil {
return err
}
// update
edit_distributor_name := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "zadtcvlf",
"name": "distributor_name",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"maraba_investments",
"farmers_center",
"farmers_world",
"farmers_desk",
"mazao_na_afya",
"modez_agrovet",
"wakulima_supplies",
"volcano",
"makutano_agrovet",
"kipkomo_agrovet",
"pioneer",
"golden_agrovet",
"skynet_agrovet",
"mkulima_bora",
"beta_green",
"mwangaza_agrovet",
"prima_met_agrovet",
"ikolomani_dairy_coop"
]
}
}`), edit_distributor_name)
collection.Schema.AddField(edit_distributor_name)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("hcgj54gqdujejom")
if err != nil {
return err
}
// update
edit_distributor_name := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "zadtcvlf",
"name": "distributor_name",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"maraba_investments",
"farmers_center",
"farmers_world",
"farmers_desk",
"mazao_na_afya",
"modez_agrovet",
"wakulima_supplies",
"volcano",
"makutano_agrovet",
"kipkomo_agrovet",
"pioneer",
"golden_agrovet",
"skynet_agrovet",
"mkulima_bora",
"beta_green",
"mwangaza_agrovet",
"prima_met_agrovet"
]
}
}`), edit_distributor_name)
collection.Schema.AddField(edit_distributor_name)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,103 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("w7vsnhq55laqara")
if err != nil {
return err
}
// update
edit_distributor_name := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "rjvhxlwa",
"name": "distributor_name",
"type": "select",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"maraba_investments",
"farmers_center",
"farmers_world",
"farmers_desk",
"mazao_na_afya",
"modez_agrovet",
"wakulima_supplies",
"volcano",
"makutano_agrovet",
"kipkomo_agrovet",
"pioneer",
"golden_agrovet",
"skynet_agrovet",
"mkulima_bora",
"beta_green",
"mwangaza_agrovet",
"prima_met_agrovet",
"ikolomani_dairy_coop"
]
}
}`), edit_distributor_name)
collection.Schema.AddField(edit_distributor_name)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("w7vsnhq55laqara")
if err != nil {
return err
}
// update
edit_distributor_name := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "rjvhxlwa",
"name": "distributor_name",
"type": "select",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"maraba_investments",
"farmers_center",
"farmers_world",
"farmers_desk",
"mazao_na_afya",
"modez_agrovet",
"wakulima_supplies",
"volcano",
"makutano_agrovet",
"kipkomo_agrovet",
"pioneer",
"golden_agrovet",
"skynet_agrovet",
"mkulima_bora",
"beta_green",
"mwangaza_agrovet",
"prima_met_agrovet"
]
}
}`), edit_distributor_name)
collection.Schema.AddField(edit_distributor_name)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,97 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("4f0a5b2wec6okxi")
if err != nil {
return err
}
// update
edit_evergrow_crops := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "5kxslfpx",
"name": "evergrow_crops",
"type": "select",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 12,
"values": [
"rice",
"coffee",
"tea",
"sugarcane",
"miraa",
"avocados",
"maize",
"potatoes",
"sorghum",
"other_fruits",
"other_vegetables",
"other_grains",
"dragonfruit",
"hay",
"beans",
"soya"
]
}
}`), edit_evergrow_crops)
collection.Schema.AddField(edit_evergrow_crops)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("4f0a5b2wec6okxi")
if err != nil {
return err
}
// update
edit_evergrow_crops := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "5kxslfpx",
"name": "evergrow_crops",
"type": "select",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 12,
"values": [
"rice",
"coffee",
"tea",
"sugarcane",
"miraa",
"avocados",
"maize",
"potatoes",
"sorghum",
"other_fruits",
"other_vegetables",
"other_grains",
"dragonfruit"
]
}
}`), edit_evergrow_crops)
collection.Schema.AddField(edit_evergrow_crops)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,97 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("uutt9wj7d5ejmhz")
if err != nil {
return err
}
// update
edit_planned_crops := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "p4n5v8yf",
"name": "planned_crops",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 12,
"values": [
"rice",
"coffee",
"tea",
"sugarcane",
"miraa",
"avocados",
"maize",
"potatoes",
"sorghum",
"other_fruits",
"other_vegetables",
"other_grains",
"dragonfruit",
"hay",
"beans",
"soya"
]
}
}`), edit_planned_crops)
collection.Schema.AddField(edit_planned_crops)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("uutt9wj7d5ejmhz")
if err != nil {
return err
}
// update
edit_planned_crops := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "p4n5v8yf",
"name": "planned_crops",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 12,
"values": [
"rice",
"coffee",
"tea",
"sugarcane",
"miraa",
"avocados",
"maize",
"potatoes",
"sorghum",
"other_fruits",
"other_vegetables",
"other_grains",
"dragonfruit"
]
}
}`), edit_planned_crops)
collection.Schema.AddField(edit_planned_crops)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,97 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("o7i7dkfc0x2bw22")
if err != nil {
return err
}
// update
edit_crops := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "ltb2rowr",
"name": "crops",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 12,
"values": [
"rice",
"coffee",
"tea",
"sugarcane",
"miraa",
"avocados",
"maize",
"potatoes",
"sorghum",
"other_fruits",
"other_vegetables",
"other_grains",
"dragonfruit",
"hay",
"beans",
"soya"
]
}
}`), edit_crops)
collection.Schema.AddField(edit_crops)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("o7i7dkfc0x2bw22")
if err != nil {
return err
}
// update
edit_crops := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "ltb2rowr",
"name": "crops",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 12,
"values": [
"rice",
"coffee",
"tea",
"sugarcane",
"miraa",
"avocados",
"maize",
"potatoes",
"sorghum",
"other_fruits",
"other_vegetables",
"other_grains",
"dragonfruit"
]
}
}`), edit_crops)
collection.Schema.AddField(edit_crops)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,97 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("5pbnsptw25ip6b1")
if err != nil {
return err
}
// update
edit_crop := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "gt06xc9v",
"name": "crop",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"rice",
"coffee",
"tea",
"sugarcane",
"miraa",
"avocados",
"maize",
"potatoes",
"sorghum",
"other_fruits",
"other_vegetables",
"other_grains",
"dragonfruit",
"hay",
"beans",
"soya"
]
}
}`), edit_crop)
collection.Schema.AddField(edit_crop)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("5pbnsptw25ip6b1")
if err != nil {
return err
}
// update
edit_crop := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "gt06xc9v",
"name": "crop",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"rice",
"coffee",
"tea",
"sugarcane",
"miraa",
"avocados",
"maize",
"potatoes",
"sorghum",
"other_fruits",
"other_vegetables",
"other_grains",
"dragonfruit"
]
}
}`), edit_crop)
collection.Schema.AddField(edit_crop)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,105 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("hcgj54gqdujejom")
if err != nil {
return err
}
// update
edit_distributor_name := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "zadtcvlf",
"name": "distributor_name",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"maraba_investments",
"farmers_center",
"farmers_world",
"farmers_desk",
"mazao_na_afya",
"modez_agrovet",
"wakulima_supplies",
"volcano",
"makutano_agrovet",
"kipkomo_agrovet",
"pioneer",
"golden_agrovet",
"skynet_agrovet",
"mkulima_bora",
"beta_green",
"mwangaza_agrovet",
"prima_met_agrovet",
"ikolomani_dairy_coop",
"bungoma_cane_growers"
]
}
}`), edit_distributor_name)
collection.Schema.AddField(edit_distributor_name)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("hcgj54gqdujejom")
if err != nil {
return err
}
// update
edit_distributor_name := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "zadtcvlf",
"name": "distributor_name",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"maraba_investments",
"farmers_center",
"farmers_world",
"farmers_desk",
"mazao_na_afya",
"modez_agrovet",
"wakulima_supplies",
"volcano",
"makutano_agrovet",
"kipkomo_agrovet",
"pioneer",
"golden_agrovet",
"skynet_agrovet",
"mkulima_bora",
"beta_green",
"mwangaza_agrovet",
"prima_met_agrovet",
"ikolomani_dairy_coop"
]
}
}`), edit_distributor_name)
collection.Schema.AddField(edit_distributor_name)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,105 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("w7vsnhq55laqara")
if err != nil {
return err
}
// update
edit_distributor_name := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "rjvhxlwa",
"name": "distributor_name",
"type": "select",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"maraba_investments",
"farmers_center",
"farmers_world",
"farmers_desk",
"mazao_na_afya",
"modez_agrovet",
"wakulima_supplies",
"volcano",
"makutano_agrovet",
"kipkomo_agrovet",
"pioneer",
"golden_agrovet",
"skynet_agrovet",
"mkulima_bora",
"beta_green",
"mwangaza_agrovet",
"prima_met_agrovet",
"ikolomani_dairy_coop",
"bungoma_cane_growers"
]
}
}`), edit_distributor_name)
collection.Schema.AddField(edit_distributor_name)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("w7vsnhq55laqara")
if err != nil {
return err
}
// update
edit_distributor_name := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "rjvhxlwa",
"name": "distributor_name",
"type": "select",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"maraba_investments",
"farmers_center",
"farmers_world",
"farmers_desk",
"mazao_na_afya",
"modez_agrovet",
"wakulima_supplies",
"volcano",
"makutano_agrovet",
"kipkomo_agrovet",
"pioneer",
"golden_agrovet",
"skynet_agrovet",
"mkulima_bora",
"beta_green",
"mwangaza_agrovet",
"prima_met_agrovet",
"ikolomani_dairy_coop"
]
}
}`), edit_distributor_name)
collection.Schema.AddField(edit_distributor_name)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,109 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("hcgj54gqdujejom")
if err != nil {
return err
}
// update
edit_distributor_name := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "zadtcvlf",
"name": "distributor_name",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"maraba_investments",
"farmers_center",
"farmers_world",
"farmers_desk",
"mazao_na_afya",
"modez_agrovet",
"wakulima_supplies",
"volcano",
"makutano_agrovet",
"kipkomo_agrovet",
"pioneer",
"golden_agrovet",
"skynet_agrovet",
"mkulima_bora",
"beta_green",
"mwangaza_agrovet",
"prima_met_agrovet",
"ikolomani_dairy_coop",
"bungoma_cane_growers",
"sochoi_agro_stores",
"lessos_agrovet_shop",
"mkulima_agro_engineer"
]
}
}`), edit_distributor_name)
collection.Schema.AddField(edit_distributor_name)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("hcgj54gqdujejom")
if err != nil {
return err
}
// update
edit_distributor_name := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "zadtcvlf",
"name": "distributor_name",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"maraba_investments",
"farmers_center",
"farmers_world",
"farmers_desk",
"mazao_na_afya",
"modez_agrovet",
"wakulima_supplies",
"volcano",
"makutano_agrovet",
"kipkomo_agrovet",
"pioneer",
"golden_agrovet",
"skynet_agrovet",
"mkulima_bora",
"beta_green",
"mwangaza_agrovet",
"prima_met_agrovet",
"ikolomani_dairy_coop",
"bungoma_cane_growers"
]
}
}`), edit_distributor_name)
collection.Schema.AddField(edit_distributor_name)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,109 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("w7vsnhq55laqara")
if err != nil {
return err
}
// update
edit_distributor_name := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "rjvhxlwa",
"name": "distributor_name",
"type": "select",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"maraba_investments",
"farmers_center",
"farmers_world",
"farmers_desk",
"mazao_na_afya",
"modez_agrovet",
"wakulima_supplies",
"volcano",
"makutano_agrovet",
"kipkomo_agrovet",
"pioneer",
"golden_agrovet",
"skynet_agrovet",
"mkulima_bora",
"beta_green",
"mwangaza_agrovet",
"prima_met_agrovet",
"ikolomani_dairy_coop",
"bungoma_cane_growers",
"sochoi_agro_stores",
"lessos_agrovet_shop",
"mkulima_agro_engineer"
]
}
}`), edit_distributor_name)
collection.Schema.AddField(edit_distributor_name)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("w7vsnhq55laqara")
if err != nil {
return err
}
// update
edit_distributor_name := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "rjvhxlwa",
"name": "distributor_name",
"type": "select",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"maraba_investments",
"farmers_center",
"farmers_world",
"farmers_desk",
"mazao_na_afya",
"modez_agrovet",
"wakulima_supplies",
"volcano",
"makutano_agrovet",
"kipkomo_agrovet",
"pioneer",
"golden_agrovet",
"skynet_agrovet",
"mkulima_bora",
"beta_green",
"mwangaza_agrovet",
"prima_met_agrovet",
"ikolomani_dairy_coop",
"bungoma_cane_growers"
]
}
}`), edit_distributor_name)
collection.Schema.AddField(edit_distributor_name)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,117 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("hcgj54gqdujejom")
if err != nil {
return err
}
// update
edit_distributor_name := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "zadtcvlf",
"name": "distributor_name",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"maraba_investments",
"farmers_center",
"farmers_world",
"farmers_desk",
"mazao_na_afya",
"modez_agrovet",
"wakulima_supplies",
"volcano",
"makutano_agrovet",
"kipkomo_agrovet",
"pioneer",
"golden_agrovet",
"skynet_agrovet",
"mkulima_bora",
"beta_green",
"mwangaza_agrovet",
"prima_met_agrovet",
"ikolomani_dairy_coop",
"bungoma_cane_growers",
"sochoi_agro_stores",
"lessos_agrovet_shop",
"mkulima_agro_engineer",
"kfa_kapsabet",
"mashambani_agrovet_lessos",
"baraton_farm_solution",
"new_kamoiywo",
"moi_agro_stores_kaptumo"
]
}
}`), edit_distributor_name)
collection.Schema.AddField(edit_distributor_name)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("hcgj54gqdujejom")
if err != nil {
return err
}
// update
edit_distributor_name := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "zadtcvlf",
"name": "distributor_name",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"maraba_investments",
"farmers_center",
"farmers_world",
"farmers_desk",
"mazao_na_afya",
"modez_agrovet",
"wakulima_supplies",
"volcano",
"makutano_agrovet",
"kipkomo_agrovet",
"pioneer",
"golden_agrovet",
"skynet_agrovet",
"mkulima_bora",
"beta_green",
"mwangaza_agrovet",
"prima_met_agrovet",
"ikolomani_dairy_coop",
"bungoma_cane_growers",
"sochoi_agro_stores",
"lessos_agrovet_shop",
"mkulima_agro_engineer"
]
}
}`), edit_distributor_name)
collection.Schema.AddField(edit_distributor_name)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,117 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("w7vsnhq55laqara")
if err != nil {
return err
}
// update
edit_distributor_name := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "rjvhxlwa",
"name": "distributor_name",
"type": "select",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"maraba_investments",
"farmers_center",
"farmers_world",
"farmers_desk",
"mazao_na_afya",
"modez_agrovet",
"wakulima_supplies",
"volcano",
"makutano_agrovet",
"kipkomo_agrovet",
"pioneer",
"golden_agrovet",
"skynet_agrovet",
"mkulima_bora",
"beta_green",
"mwangaza_agrovet",
"prima_met_agrovet",
"ikolomani_dairy_coop",
"bungoma_cane_growers",
"sochoi_agro_stores",
"lessos_agrovet_shop",
"mkulima_agro_engineer",
"kfa_kapsabet",
"mashambani_agrovet_lessos",
"baraton_farm_solution",
"new_kamoiywo",
"moi_agro_stores_kaptumo"
]
}
}`), edit_distributor_name)
collection.Schema.AddField(edit_distributor_name)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("w7vsnhq55laqara")
if err != nil {
return err
}
// update
edit_distributor_name := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "rjvhxlwa",
"name": "distributor_name",
"type": "select",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"maraba_investments",
"farmers_center",
"farmers_world",
"farmers_desk",
"mazao_na_afya",
"modez_agrovet",
"wakulima_supplies",
"volcano",
"makutano_agrovet",
"kipkomo_agrovet",
"pioneer",
"golden_agrovet",
"skynet_agrovet",
"mkulima_bora",
"beta_green",
"mwangaza_agrovet",
"prima_met_agrovet",
"ikolomani_dairy_coop",
"bungoma_cane_growers",
"sochoi_agro_stores",
"lessos_agrovet_shop",
"mkulima_agro_engineer"
]
}
}`), edit_distributor_name)
collection.Schema.AddField(edit_distributor_name)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,92 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("uutt9wj7d5ejmhz")
if err != nil {
return err
}
// update
edit_county := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "murxdavm",
"name": "county",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"kirinyaga",
"muranga",
"nakuru",
"meru",
"uasin_gishu",
"kajiado",
"kericho",
"elgeyo_marakwet",
"kakamega",
"bungoma",
"nyandarua",
"nandi_county"
]
}
}`), edit_county)
collection.Schema.AddField(edit_county)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("uutt9wj7d5ejmhz")
if err != nil {
return err
}
// update
edit_county := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "murxdavm",
"name": "county",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"kirinyaga",
"muranga",
"nakuru",
"meru",
"uasin_gishu",
"kajiado",
"kericho",
"elgeyo_marakwet",
"kakamega",
"bungoma",
"nyandarua",
"nandi"
]
}
}`), edit_county)
collection.Schema.AddField(edit_county)
return dao.SaveCollection(collection)
})
}

View File

@ -0,0 +1,92 @@
package migrations
import (
"encoding/json"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/daos"
m "github.com/pocketbase/pocketbase/migrations"
"github.com/pocketbase/pocketbase/models/schema"
)
func init() {
m.Register(func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("uutt9wj7d5ejmhz")
if err != nil {
return err
}
// update
edit_county := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "murxdavm",
"name": "county",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"kirinyaga",
"muranga",
"nakuru",
"meru",
"uasin_gishu",
"kajiado",
"kericho",
"elgeyo_marakwet",
"kakamega",
"bungoma",
"nyandarua",
"nandi"
]
}
}`), edit_county)
collection.Schema.AddField(edit_county)
return dao.SaveCollection(collection)
}, func(db dbx.Builder) error {
dao := daos.New(db);
collection, err := dao.FindCollectionByNameOrId("uutt9wj7d5ejmhz")
if err != nil {
return err
}
// update
edit_county := &schema.SchemaField{}
json.Unmarshal([]byte(`{
"system": false,
"id": "murxdavm",
"name": "county",
"type": "select",
"required": true,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"kirinyaga",
"muranga",
"nakuru",
"meru",
"uasin_gishu",
"kajiado",
"kericho",
"elgeyo_marakwet",
"kakamega",
"bungoma",
"nyandarua",
"nandi_county"
]
}
}`), edit_county)
collection.Schema.AddField(edit_county)
return dao.SaveCollection(collection)
})
}