
create table if not exists seasons(
id integer not null,
name varchar(100) not null,
active integer not null default 1,
created_at varchar(100) not null
);


create table province(
id integer not null,
names varchar(100) not null
);





create table if not exists users(

id integer not null,
name varchar(100) not null,
surname varchar(100) not null,
username varchar(100) not null,
hash varchar(100) not null,
rightsid integer not null,
active integer not null default 1,
access_code integer not null,
created_at varchar(100) not null

);



create table if not exists user_home(
id integer primary key autoIncrement,
userid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id)
);




create table if not exists products(
id integer primary key autoIncrement,
name varchar(100) not null,
units varchar(100) not null
);



create table if not exists prices(
id integer primary key autoIncrement,
userid integer not null,
productid integer not null,
amount double(100,2) not null default 0,
seasonid integer not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(productid) references products(id)
);


create table if not exists growers(
id integer primary key autoIncrement,
userid integer not null,
name varchar(100) not null,
surname varchar(100) not null,
grower_num varchar(100),
area varchar(100) not null,
province varchar(100),
phone varchar(100),
id_num varchar(100) not null,
seasonid integer not null,
sync integer not null default 0,
created_at varchar(100),
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id)
);



create table if not exists grower_profile(
id integer primary key autoIncrement,
growerid integer not null,
image blob not null,
created_at varchar(100) not null
);


create table if not exists lat_long(
id integer primary key autoIncrement,
userid integer not null ,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
seasonid integer not null,
hectares varchar(100),
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(growerid) references growers(id),
foreign key(seasonid) references seasons(id)
);


create table if not exists grower_farm(
id integer primary key autoIncrement,
userid integer not null ,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
seasonid integer not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(growerid) references growers(id),
foreign key(seasonid) references seasons(id)
);



create table if not exists grower_visits(
id integer primary key autoIncrement,
userid integer not null,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
description varchar(100) not null,
conditions varchar(100) not null,
other varchar(100) not null,
seasonid integer not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(growerid) references growers(id),
foreign key(seasonid) references seasons(id)
);





create table if not exists assessments(
id integer primary key autoIncrement,
userid integer not null,
name varchar(100) not null unique,
assessment_typeid integer not null default 1,
number integer not null default 1,
foreign key(userid) references users(id),
foreign key(assessment_typeid) references assessment_type(id)
);



create table if not exists quantitative_assessments(
id integer primary key autoIncrement,
userid integer not null,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
description varchar(100) not null,
number varchar(100) not null,
seasonid integer not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(growerid) references growers(id),
foreign key(seasonid) references seasons(id)
);







create table if not exists assessment_images(
id integer primary key autoIncrement,
userid integer not null,
growerid integer not null,
seasonid integer not null,
url varchar(100) not null,
image blob ,
description varchar(100) not null,
conditions varchar(100) not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(growerid) references growers(id),
foreign key(seasonid) references seasons(id)
);


create table if not exists grower_image(
id integer primary key autoIncrement,
userid integer not null,
growerid integer not null,
seasonid integer not null,
image varchar(1000000) not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(growerid) references growers(id),
foreign key(seasonid) references seasons(id)
);









create table if not exists sod(
id integer primary key autoIncrement,
userid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
seasonid integer not null,
time varchar(100) not null,
eod integer not null default 0 ,
sync integer not null default 0,
created_at varchar(100) not null,
eod_created_at TEXT not null unique,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id)
);








create table if not exists road_blocks(
id integer primary key autoIncrement,
userid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
seasonid integer not null,
time varchar(100) not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id)
);



create table if not exists eod(
id integer primary key autoIncrement,
userid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
seasonid integer not null,
time varchar(100) not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id)
);



create table if not exists off_route(

id integer primary key autoIncrement,
userid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
seasonid integer not null,
time varchar(100) not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id)
);




create table if not exists last_eod_date(
id integer primary key autoIncrement,
created_at varchar(100) not null 
);



create table if not exists exemptions(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
exemption_date varchar(100) not null unique,
description varchar(100) not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id)
);




create table if not exists recovery(
id integer primary key autoIncrement,
grower_num varchar(100) not null,
seasonid integer not null,
userid integer not null,
bales integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id)
);


create table if not exists activation(
id integer primary key autoIncrement,
activation_key varchar(100) not null,
startDate varchar(100) not null,
endDate varchar(100) not null,
functions integer not null default 0,
created_at varchar(100) not null
);


create table if not exists seed_beds(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
no_of_irr_beds integer not null default 0,
no_of_dry_beds integer not null default 0,
buying_seedlings_for varchar(100),
varieties_irr varchar(100),
varieties_dry varchar(100),
latitude varchar(100) not null,
longitude varchar(100) not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)

);


create table if not exists seedling_quality(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
excellent integer not null default 0,
standard integer not null default 0,
average integer not null default 0,
poor integer not null default 0,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)
);


create table if not exists plant_irrigated(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
ha_planted_to_date varchar(100),
ha varchar(100),
date_of_plant varchar(100),
crop_stand_perc varchar(100),
crop_unifomity_perc varchar(100),
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)

);


create table if not exists planting_dryLand(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
ha_planted_to_date varchar(100),
ha varchar(100),
date_of_plant varchar(100),
crop_stand_perc varchar(100),
crop_unifomity_perc varchar(100),
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)

);


create table if not exists crop_growth(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
quarter_grown_5_7 integer not null default 0,
half_grown_8_12 integer not null default 0,
three_quarters_13_17 integer not null default 0,
full_grown_18_22 integer not null default 0,
fully_developed integer not null default 0,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)
);



create table if not exists crop_development(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
light_yellow integer default 0,
light_green integer default 0,
medium integer default 0,
heavy_and_dark integer default 0,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)

);


create table if not exists cultural_practices(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
weed_infestation_level_perc varchar(100),
weed_control_method varchar(100),
topping_level varchar(100),
basal_plant_fertilisation_kg_ha varchar(100),
suckering integer not null default 0,
post_topping_unifomity_perc varchar(100),
pets_and_disease_management varchar(100),
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)

);




create table if not exists barn_repair_and_maintenance(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
barn_not_repaired integer not null default 0,
barn_under_repair integer not null default 0,
finished_repaired integer not null default 0,
barn_working_well integer not null default 0,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)

);



create table if not exists ploughing(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
no_of_plants integer not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)
);




create table if not exists fertilization_ammonium(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
kg_per_ha varchar(100) not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)
);




create table if not exists fertilization_potassium(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
kg_per_ha varchar(100) not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)
);







create table if not exists reaping(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
top_leaf integer not null default 0,
lugs integer not null default 0,
cutters integer not null default 0,
prime integer not null default 0,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)
);







create table if not exists curing(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
reap_decription varchar(100) not null,
yellowing integer not null default 0,
leaf_drying integer not null default 0,
stem_drying integer not null default 0,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)
);





create table if not exists barn_location(
id integer primary key autoIncrement,
userid integer not null ,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
seasonid integer not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(growerid) references growers(id),
foreign key(seasonid) references seasons(id)
);





create table if not exists  farm_mapping(

id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
first_lat varchar(100) not null,
first_long varchar(100) not null,
second_lat varchar(100) not null,
second_long varchar(100) not null,
third_lat varchar(100) not null,
third_long varchar(100) not null,
forth_lat varchar(100) not null,
forth_long varchar(100) not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)

);


create table if not exists  mapped_hectares(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
ha varchar(100) not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)
);



create table if not exists  mapped_hail_hectares(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
ha varchar(100) not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)
);




create table if not exists estimates(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
varieties varchar(100) not null,
estimate varchar(100) not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)
);







create table if not exists data_collection(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
grower_age integer not null,
grower_sex integer not null ,
number_of_works integer not null,
income_per_month double(100,2) not null,
number_of_kids integer not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)
);


create table if not exists kids_age(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
kid_age integer not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)
);




create table if not exists education_level(
id integer not null,
description varchar(100) not null
);


create table if not exists grower_level_of_education(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
education_level_id integer not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(education_level_id) references education_level(id),
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)

);



create table if not exists health_conditions(
id integer not null,
description varchar(100) not null
);



create table if not exists grower_health(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
health_conditionid integer not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(health_conditionid) references health_conditions(id),
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)
);





create table if not exists  hail_strike_mapping(

id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
first_lat varchar(100) not null,
first_long varchar(100) not null,
second_lat varchar(100) not null,
second_long varchar(100) not null,
third_lat varchar(100) not null,
third_long varchar(100) not null,
forth_lat varchar(100) not null,
forth_long varchar(100) not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)

);



create table if not exists hail_strike(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
percentage_strike varchar(100) not null,
strike_date varchar(100) not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)

);










create table if not exists truck_destination(
id integer not null,
userid integer not null,
trucknumber varchar(100) not null,
driver_name varchar(100) not null,
driver_surname varchar(100) not null,
destination varchar(100) not null,
close_open integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id)
);


create table if not exists disbursement(
id integer not null,
disbursement_trucksid integer not null,
userid integer not null,
productid integer not null,
storeid integer not null,
quantity integer not null,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(productid) references products(id),
foreign key(storeid) references store(id),
foreign key(disbursement_trucksid) references truck_destination(id)
);



create table  if not exists truck_to_grower(
id integer primary key autoIncrement,
userid integer not null,
growerid integer not null,
disbursement_trucksid integer not null,
productid integer not null,
quantity integer not null,
created_at varchar(100) not null,
datetime TIMESTAMP not null,
foreign key(userid) references users(id),
foreign key(productid) references products(id),
foreign key(disbursement_trucksid) references truck_destination(id),
foreign key(growerid) references growers(id)
);





create table if not exists loans_2_0(
id integer primary key autoIncrement,
userid integer not null,
growerid integer not null,
productid integer not null,
quantity integer not null,
receipt_number varchar(100) not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
seasonid integer not null,
hectares varchar(100),
android_captureid integer not null default 0,
disbursement_trucksid integer not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(growerid) references growers(id),
foreign key(seasonid) references seasons(id),
foreign key(productid) references products(id),
foreign key(disbursement_trucksid) references truck_destination(id)
);


create table if not exists protocol(
id integer primary key autoIncrement ,
description varchar(100)  not null
);



create table if not exists reg_location(
id integer primary key autoIncrement,
userid integer not null ,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
seasonid integer not null,
hectares varchar(100),
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(growerid) references growers(id),
foreign key(seasonid) references seasons(id)
);



create table if not exists distance(
id integer primary key autoIncrement,
userid integer not null ,
distance double(100,2) not null default 0,
seasonid integer not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id)
);



create table if not exists grower_new_image(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
image_location varchar(100) not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(growerid) references growers(id),
foreign key(seasonid) references seasons(id)
);


create table if not exists grower_farm_image(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
image_location varchar(100) not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(growerid) references growers(id),
foreign key(seasonid) references seasons(id)
);




create table if not exists grower_signatures(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
image_location varchar(100) not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(growerid) references growers(id),
foreign key(seasonid) references seasons(id)
);




create table if not exists grower_id_image(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
image_location varchar(100) not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(growerid) references growers(id),
foreign key(seasonid) references seasons(id)
);



create table if not exists hours_worked(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
hours doubl(100,2) not null default 0,
created_at varchar(100) not null,
sync integer not null default 0,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id)
);


create table if not exists assign_bale_tags(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
bale_tag varchar(100) not null,
created_at varchar(100) not null,
sync integer not null default 0,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)
);


create table if not exists bale_collector(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
name varchar(100) not null,
surname varchar(100) not null,
id_num varchar(100) not null,
transporter_number varchar(100) not null,
number_plate varchar(100) not null,
created_at varchar(100) not null,
sync integer not null default 0,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id)
);






create table if not exists bale_collector_delivery_note(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
bale_collectorid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
created_at varchar(100) not null,
open_close integer not null default 0,
sync integer not null default 0,
foreign key(userid) references users(id),
foreign key(bale_collectorid) references bale_collector(id),
foreign key(seasonid) references seasons(id)
);





create table if not exists collector_id_num(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
bale_collector_delivery_noteid integer not null,
image_location varchar(100) not null,
created_at varchar(100) not null,
sync integer not null default 0,
foreign key(userid) references users(id),
foreign key(bale_collector_delivery_noteid) references bale_collector_delivery_note(id),
foreign key(seasonid) references seasons(id)
);



create table if not exists collector_signature(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
bale_collector_delivery_noteid integer not null,
image_location varchar(100) not null,
created_at varchar(100) not null,
sync integer not null default 0,
foreign key(userid) references users(id),
foreign key(bale_collector_delivery_noteid) references bale_collector_delivery_note(id),
foreign key(seasonid) references seasons(id)
);




create table if not exists bales_collected(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
bale_collector_delivery_noteid integer not null,
growerid integer not null,
bale_tag varchar(100) not null,
latitude varchar(100) not nll,
longitude varchar(100) not null,
created_at varchar(100) not null,
sync integer not null default 0,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(bale_collector_delivery_noteid) references bale_collector_delivery_note(id),
foreign key(growerid) references growers(id)
);



create table if not exists grower_bale_signature(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
bale_collector_delivery_noteid integer not null,
growerid integer not null,
image_location varchar(100) not null,
created_at varchar(100) not null,
sync integer not null default 0,
foreign key(userid) references users(id),
foreign key(bale_collector_delivery_noteid) references bale_collector_delivery_note(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)
);



create table if not exists field_officer_task(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
task_url varchar(100) not null,
description varchar(100) not null,
duration_days integer not null,
task_min_growers integer not null default 20,
created_at varchar(100) not null,
end_at varchar(100) not null,
active integer not null default 1,
sync integer not null default 0,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id)
);




create table if not exists task_viewer(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
task_url varchar(100) not null,
duration_days integer not null,
created_by_id integer not null,
task_min_growers integer not null default 20,
created_at varchar(100) not null,
active integer not null default 1,
sync integer not null default 0,
foreign key(userid) references users(id),
foreign key(created_by_id) references users(id),
foreign key(seasonid) references seasons(id)
);



create table if not exists task_grower_data(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
task_url varchar(100) not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
created_at varchar(100) not null,
time_created varchar(100) not null,
sync integer not null default 0,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)
);



create table if not exists bales_collected_total(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
bale_collector_delivery_noteid integer not null,
growerid integer not null,
tags_total integer not null,
sync integer not null default 0,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(bale_collector_delivery_noteid) references bale_collector_delivery_note(id),
foreign key(growerid) references growers(id)
);



create table if not exists received_bales(
id integer primary key autoIncrement,
userid integer not null,
seasonid integer not null,
growerid integer not null,
bale_tag varchar(100) not null,
created_at varchar(100) not null,
sync integer not null default 0,
foreign key(userid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id)
);

create table if not exists live_location_userid(
id integer primary key autoIncrement,
userid integer not null,
firebaseid varchar(200) not null,
active integer not null default 1,
created_at varchar(100) not null,
foreign key(userid) references users(id)
);





create table if not exists grower_captured_loans(
id integer primary key autoIncrement,
userid integer not null,
growerid integer not null,
seasonid integer not null,
productid integer not null,
receipt_number varchar(200) not null,
quantity integer not null,
verified integer not null,
created_at varchar(100) not null,
foreign key(userid) references users(id)
);


create table if not exists scheme(
id integer primary key autoIncrement,
userid integer not null,
description varchar(100) not null unique,
foreign key(userid) references users(id)
);




create table if not exists scheme_hectares(
id integer primary key autoIncrement,
userid integer not null,
schemeid integer not null,
seasonid integer not null,
quantity varchar(100) not null,
foreign key(userid) references users(id),
foreign key(schemeid) references scheme(id),
foreign key(seasonid) references seasons(id)
);



create table if not exists scheme_hectares_products(
id integer primary key autoIncrement,
userid integer not null,
scheme_hectaresid integer not null,
productid integer not null,
quantity varchar(100) not null,
foreign key(userid) references users(id),
foreign key(scheme_hectaresid) references scheme_hectares(id),
foreign key(productid) references products(id)
);


create table if not exists scheme_hectares_growers(
id integer primary key autoIncrement,
userid integer not null,
scheme_hectaresid integer not null,
growerid integer not null,
foreign key(userid) references users(id),
foreign key(scheme_hectaresid) references scheme_hectares(id),
foreign key(growerid) references growers(id)
);





create table if not exists growers_otp (
  id integer primary key autoIncrement,
  userid integer not null,
  seasonid integer not null,
  growerid integer not null,
  used integer not null default 0,
  sent integer not null default 0,
  sync integer not null default 0,
  otp varchar(255) NOT NULL unique,
  foreign key(userid) references users(id),
  foreign key(seasonid) references seasons(id),
  foreign key(growerid) references growers(id)
);



create table if not exists updated_grower_phone(
  id integer primary key autoIncrement,
  userid integer not null,
  growerid integer not null,
  sync integer not null default 0,
  foreign key(userid) references users(id),
  foreign key(growerid) references growers(id)
);




create table if not exists otp_to_product(
  id integer primary key autoIncrement,
  userid integer not null,
  seasonid integer not null,
  growerid integer not null,
  productid integer not null,
  quantity integer not null,
  otp varchar(255) NOT NULL unique,
  sync integer not null default 0,
  foreign key(userid) references users(id),
  foreign key(growerid) references growers(id)
);




create table if not exists battery_level_report(
  id integer primary key autoIncrement,
  userid integer not null,
  seasonid integer not null,
  battery_level varchar(255) NOT NULL,
  created_at varchar(100) not null,
  time varchar(100) not null,
  sync integer not null default 0,
  foreign key(userid) references users(id),
  foreign key(seasonid) references seasons(id)
);



create table if not exists start_battery_level(
  id integer primary key autoIncrement,
  userid integer not null,
  seasonid integer not null,
  battery_level varchar(255) NOT NULL,
  time varchar(100) not null,
  created_at varchar(100) not null,
  sync integer not null default 0,
  foreign key(userid) references users(id),
  foreign key(seasonid) references seasons(id)
);









create table if not exists end_battery_level(
  id integer primary key autoIncrement,
  userid integer not null,
  seasonid integer not null,
  battery_level varchar(255) NOT NULL,
  time varchar(100) not null,
  created_at varchar(100) not null,
  sync integer not null default 0,
  foreign key(userid) references users(id),
  foreign key(seasonid) references seasons(id)
);










create table if not exists leave_form(
  id integer primary key autoIncrement,
  userid integer not null,
  seasonid integer not null,
  leave_type varchar(100) not null,
  description varchar(255) not null,
  days integer not null default 1,
  state integer not null default 0,
  leave_date varchar(100) not null,
  created_at varchar(100) not null,
  sync integer not null default 0,
  foreign key(userid) references users(id),
  foreign key(seasonid) references seasons(id)
);




create table if not exists grower_finger_print(
  id integer primary key autoIncrement,
  userid integer not null,
  seasonid integer not null,
  growerid integer not null,
  pin text not null,
  feature text not null,
  created_at varchar(100) not null,
  sync integer not null default 0,
  foreign key(userid) references users(id),
  foreign key(seasonid) references seasons(id),
  foreign key(growerid) references growers(id)

);




create table if not exists grower_bale_booking(
  id integer primary key autoIncrement,
  userid integer not null,
  booking_username varchar(100) not null,
  seasonid integer not null,
  growerid integer not null,
  bales integer not null,
  booking_date varchar(100) not null,
  created_time varchar(100) not null,
  created_at varchar(100) not null,
  sync integer not null default 0,
  foreign key(userid) references users(id),
  foreign key(seasonid) references seasons(id),
  foreign key(growerid) references growers(id)
);





create table if not exists grower_visit_schedule(
  id integer primary key autoIncrement,
  userid integer not null,
  growerid integer not null,
  seasonid integer not null,
  sync integer not null default 0,
  created_at varchar(100) not null,
  end_at varchar(100) not null,
  foreign key(userid) references users(id),
  foreign key(seasonid) references seasons(id),
  foreign key(growerid) references growers(id)
);


create table if not exists grower_groups(
id integer primary key autoIncrement,
description varchar(100) not null
);


create table if not exists grower_field_officer_groups(
id integer primary key autoIncrement,
userid integer not null,
growerid integer not null,
field_officerid integer not null,
grower_groupid integer not null,
seasonid integer not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(field_officerid) references users(id),
foreign key(seasonid) references seasons(id),
foreign key(growerid) references growers(id),
foreign key(grower_groupid) references grower_groups(id)
);



create table if not exists seedbed_location(
id integer primary key autoIncrement,
userid integer not null ,
growerid integer not null,
latitude varchar(100) not null,
longitude varchar(100) not null,
seasonid integer not null,
sync integer not null default 0,
created_at varchar(100) not null,
foreign key(userid) references users(id),
foreign key(growerid) references growers(id),
foreign key(seasonid) references seasons(id)
);


public static final String TABLE_GROWER_GROUPS="grower_groups";

public static final String TABLE_GROWER_FIELD_OFFICER_GROUPS="grower_field_officer_groups";

public static final String TABLE_GROWER_VISIT_SCHEDULE="grower_visit_schedule";

public static final String TABLE_GROWER_BALE_BOOKING="grower_bale_booking";

public static final String TABLE_BALES_COLLECTED="bales_collected";
public static final String TABLE_GROWER_BALE_SIGNATURE="grower_bale_signature";
public static final String TABLE_COLLECTOR_SIGNATURE="collector_signature";
public static final String TABLE_COLLECTOR_ID_NUM="collector_id_num";
public static final String TABLE_BALE_COLLECTOR_DELIVERY_NOTE="bale_collector_delivery_note";
public static final String TABLE_BALE_COLLECTOR="bale_collector";
public static final String TABLE_BALES_COLLECTED_TOTAL="bales_collected_total";
public static final String TABLE_ASSIGN_BALE_TAGS="assign_bale_tags";
public static final String TABLE_TASK_GROWER_DATA="task_grower_data";

public static final String TABLE_RECEIVED_BALES="received_bales";
public static final String TABLE_GROWER_CAPTURED_LOANS="grower_captured_loans";

public static final String TABLE_GROWER_OTP="growers_otp";

public static final String TABLE_UPDATE_GROWER_PHONE="updated_grower_phone";


public static final String TABLE_START_BATTERY_LEVEL="start_battery_level";

public static final String TABLE_END_BATTERY_LEVEL="end_battery_level";

public static final String TABLE_BATTERY_LEVEL_REPORT="battery_level_report";


public static final String TABLE_LEAVE_FORM="leave_form";

public static final String TABLE_GROWER_FINGER_PRINT="grower_finger_print";

