Database / Farmer

ie_flat_entity

The main farmer list. One flat, denormalised row per farmer with geography, demographics, endorsement state and many UI flags. Mirrors server report datasets such as PlusOneWorkNodeFarmerListGeoWise.

Table factsheetagri_db
Written by
  • Data down-sync screens (DataSetupViewModel, UnitDataSetupViewModel)
  • SetupIeFlatSchemaData / SetupIeFlatSchemaPieData / SetupForUnitInChargeLogin
  • Add farmer (BridgeSyncHelper.createIE -> Repo.createFlatIe)
  • Portfolio save (IEPortfolioDao.savePortfolioChildEntities sets hasAGrade, hasCompactBlock, lastPortfolio*)
  • Farming model download (sets hasATM)
  • Endorsement screens (bulk status updates)
  • Per-farmer fetch workers (fetch flags)
Read by
  • Farmer list (IeFragment, IeViewModel, IeAdapter)
  • VO/SHG filters
  • Endorsements (view/endorsements/*)
  • Compact block farmer picker (CompactBlockViewModel)
  • Land asset (LandAssetViewModel)
  • Farmer detail (OptionFragment, via uuid)
  • Data-setup workers (pending fetch queries)
Filled from
GET gateway/commons-report-service/api/v1/datasets/name/PlusOneWorkNodeFarmerListGeoWise[Unit]/execute
GET .../datasets/name/PlusOneWorkNodeFarmerListGeoWiseCount[Unit]/execute
GET rtld/api/dataset/v1/execute (endorsement for VO)
Dataset AAP2024_25 and AAP2025_26 (AAP JSON columns)
Dataset PLUS_ONE_FARMING_CATEGORY_LAST_UPDATE_DATE
Sync
Has opId and syncStatus (no appId). A farmer added on the device is queued as sync entity IE_FLAT. Separate flags (hasSyncErrors, isLandAssetFetched, isPortfolioFetched, isATMFetched, assessmentFetchStatus, isAllDataLoaded) track per-farmer download progress and errors.
Source
data/src/main/java/org/mindtree/app/agricultor/data/entity/IEFlatEntity.kt

Columns

ColumnTypeNullKeyMeaning
uniqueIdentifierINTEGERNoPKLocal autoincrement primary key. Changes when the row is replaced by insertIEList. Autoincrement.
vOIdTEXTYesAlias id of the farmer's VO WorkNode. Used as the VO code/entity id in endorsements and analytics.
remarkTEXTYesData-quality remark from the server dataset, e.g. ERROR | CORRECTED | MEPMA-ERROR. Shown as a coloured chip.
villagePhaseTEXTYesProgramme phase of the village.
uuidTEXTNoIndexFarmer alias. Equals ie.aliasId and legacy ie.aliasId. Unique. Index: unique.
districtNameTEXTYesDistrict name from the server farmer dataset.
mandalOLTPIdTEXTYesServer (OLTP) id of the farmer's mandal, from the farmer dataset. Not read by the app.
maritalStatusCodeTEXTYesReference data code.
dOBTEXTYesDate of birth from the server farmer dataset (text). Not read by the app.
panchayatOLTPIdTEXTYesServer (OLTP) id of the farmer's panchayat, from the farmer dataset. Not read by the app.
idINTEGERYesServer row id. Null for farmers not yet synced.
sHGOLTPIdTEXTYesServer (OLTP) id of the farmer's Self-Help Group, from the farmer dataset. Not read by the app.
districtOLTPIdTEXTYesServer (OLTP) id of the farmer's district, from the farmer dataset. Not read by the app.
relationshipCodeTEXTYesReference data code.
memberRegDateTEXTYesFarmer registration date, yyyy-MM-dd. Compared with the new-farmer cut-off date.
husbandFatherNameSurnameTEXTYesSurname of the husband/father. Merged into husbandFatherName and cleared on download.
educationalQualificationCodeTEXTYesReference data code.
memberIDTEXTYesProgramme member id.
districtCodeTEXTYesReference data code.
mandalCodeTEXTYesReference data code.
memberAgeTEXTYesAge in years (text).
maritualStatusTEXTYesMarital status label from the server dataset (column name typo).
habitationCodeTEXTYesAlias id of the farmer's habitation WorkNode (= ie.habitatAliasId).
memberPhnoTEXTYesPhone number. PII.
memberNameTEXTYesFirst name of the farmer (first word of the full name).
villageCodeTEXTYesAlias id of the farmer's village WorkNode (= ie.villageAliasId).
educationalQualificationTEXTYesEducation label from the server dataset.
iSActiveTEXTYesActive flag from the dataset (text).
villageNameTEXTYesName of the farmer's village (copied to ie.village).
categoryIDTEXTYesNo description in code.
sHGIDTEXTYesId of the farmer's SHG. Used as the SHG entity id in endorsements.
iEOLTPIdTEXTYesServer IE id. The real join key: equals owningEntityId in assets, portfolio and farming_model, entityId in endorsement_entity, iEId in sync_errors.
panchayatCodeTEXTYesReference data code.
vOOLTPIdTEXTYesServer (OLTP) id of the farmer's VO, from the farmer dataset. Not read by the app.
memberGenderTEXTYesGender: "M" / "F" from the dataset, or GENDER.MALE | GENDER.FEMALE | GENDER.TRANSGENDER for app-created farmers.
iSDisabledTEXTYesDisability flag (text).
panchayatNameTEXTYesPanchayat name from the server farmer dataset.
habitationNameTEXTYesName of the farmer's habitation (= ie.workNodeHabitat).
memberSurnameTEXTYesRest of the farmer name after the first word.
categoryCodeTEXTYesReference data code.
categoryNameTEXTYesFarmer category as "baseCategory/currentCategory" text, e.g. "C1 (2021–22)/Farmer". The part after "/" drives the C4 / C5 / Farmer checks.
aadharNoTEXTYesAadhaar number. PII, stored unencrypted.
sHGNameTEXTYesSHG name; "Non-SHG" when the farmer has no SHG.
wellbeingCodeTEXTYesWellbeing category code.
rationCardNumberTEXTYesRation card number. PII.
habitationOLTPIdTEXTYesServer (OLTP) id of the farmer's habitation, from the farmer dataset. Not read by the app.
mandalNameTEXTYesMandal name from the server farmer dataset.
vONameTEXTYesName of the farmer's VO.
vOFormationDateTEXTYesVO formation date from the server farmer dataset (text). Not read by the app.
villageOLTPIdTEXTYesServer (OLTP) id of the farmer's village, from the farmer dataset. Not read by the app.
sHGRegistrationDateTEXTYesSHG registration date from the server farmer dataset (text). Not read by the app.
husbandFatherNameTEXTYesSpouse name when married, otherwise father name (surname merged in on download).
lifeStatusTEXTYesLIFE_STATUS.ACTIVE | LIFE_STATUS.INACTIVE.
inActiveReasonTEXTYesReason given when the row was deactivated.
annualActionPlanDataTEXTYesJSON blob: AAP 2024-25 data.
annualActionPlanData2526TEXTYesJSON blob: AAP 2025-26 data (year-specific column).
NFCategory2526TEXTYesJSON: natural farming category 2025-26.
NFJourneyTEXTYesJSON: natural farming journey.
opIdTEXTYesId of the last queued operation in the library queue (SYNC_QUEUE_DB).
syncStatusTEXTNoSYNC_NOT_INITIALIZED | IN_SYNC_QUEUE | SYNC_DONE (default).
interestedInTradeINTEGERYes1 if interested in trade.
currentCategoryTEXTYesCurrent farming category.
endorsementStatusTEXTYesnull = not endorsed; PENDING | ENDORSED | FLAGGED | FOR_REVIEW.
endorsedByTEXTYesWho endorsed the farmer.
endorsedTimeINTEGERYesWhen endorsed (epoch millis).
hasATMINTEGERYes1 when any ATM farming model exists.
hasAGradeINTEGERYes1 if any PLI has practice AP-GOV-KAP-A_GRADE.
hasCompactBlockINTEGERYesFollows PLI.isLinkedToCompactBlock (last PLI wins).
hasSyncErrorsINTEGERYes1 when the farmer has unprocessed sync_errors (red badge).
appCreatedAtTEXTYesCreated on device (epoch millis). Type differs between tables (TEXT vs INTEGER).
lastPortfolioCreatedDataTEXTYesDate of last portfolio (column name typo for "Date").
lastPortfolioCreatedSeasonTEXTYesSeason of last portfolio.
enteredPortfolioMonthsTEXTYesMonths with portfolio entries, joined with " , ".
gapStartDateTEXTYesDate the current farmer category was last changed, ISO-8601 local time "yyyy-MM-ddTHH:mm:ss". Reset when the category changes on the Add farmer screen.
lastPortfolioSwipeRefreshAtTEXTYesLast pull-to-refresh of the portfolio.
isLandAssetFetchedINTEGERYes0 = land assets not yet downloaded.
isPortfolioFetchedINTEGERYes0 = portfolio not yet downloaded.
isATMFetchedINTEGERYes0 = farming models not yet downloaded.
assessmentDoneINTEGERNo1 when an assessment exists.
hasPortfolioINTEGERNo1 when the farmer has a portfolio.
assessmentFetchStatusINTEGERNo0 = assessment not yet downloaded.
isAllDataLoadedINTEGERNo1 when all per-farmer data is downloaded.

Notes

  • Joined to other tables only by convention: uuid = ie.aliasId, iEOLTPId = owningEntityId elsewhere. No foreign keys.
  • Two insert paths: insertFlatSchemaData uses IGNORE on conflict (never refreshes), insertIEList uses REPLACE (deletes and recreates the row).
  • About 30 single-column UPDATE queries keep the derived flags in step.
  • getFarmerByComposite: farmers in a VO whose SHG id and name are in the selected lists (or have no SHG), synced only. Feeds the compact-block farmer picker.
  • getVoByUniqueIdandName returns one row per VO by MIN(id).
  • getIeIdsOfPendingLandAssetFetch / PortfolioFetch / ATMFetch select farmers whose per-farmer download is not finished.
  • updateEndorsementFieldsForVo / ForSHG stamp the status on every synced farmer of a VO or SHG.
  • Possible bug · unverified hasCompactBlock loops over all PLIs and the last one wins, so a linked PLI followed by an unlinked one resets it to 0.
  • Possible bug · unverified insertIEList (REPLACE) wipes device-only columns (hasATM, hasAGrade, hasCompactBlock, fetch flags, AAP JSON) and changes uniqueIdentifier.
  • Possible bug · unverified getVoByUniqueIdandName drops farmers that are not yet synced (id is null).
  • Possible bug · unverified queries compare iEOLTPId (TEXT) with 0 (integer).
  • Missing indexes on iEOLTPId, sHGID, vOId, sHGName.