Advertisement
Guest User

meh

a guest
Oct 15th, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // A computer made me// TODO: Make this a configuration option
  2. var knex = require("knex")({
  3.     client: "pg",
  4.     connection: {
  5.       host: "localhost",
  6.       user: "postgres",
  7.       password: "",
  8.       database: "geodb"
  9.     },
  10.     pool: { min: 0, max: 7 }
  11.   });
  12.  
  13.   const argv = require("yargs").argv;
  14.   const uuidv4 = require("uuid/v4");
  15.   const prompts = require("prompts");
  16.   const fs = require("fs");
  17.   const fsPromises = fs.promises;
  18.   const dropstream = require("dropbox-stream");
  19.   const shapefile = require("shapefile");
  20.   const util = require("util");
  21.   const exec = util.promisify(require("child_process").exec);
  22.   const path = require("path");
  23.   const turf = require("turf");
  24.  
  25.   const dropboxAccessToken = process.env.DROPBOX_ACCESS_TOKEN;
  26.   const silent = argv.silent;
  27.   const fieldMaps = {};
  28.   const relationMaps = {};
  29.   let downloadFilesAgain = false;
  30.  
  31.   const writeToFile = (contents) => {
  32.     fs.appendFileSync(`migrate_logs.txt`, contents);
  33.     }
  34.  
  35.   // This function will do an update on insertion conflict
  36.   // It uses the unique() method of knex to determine what
  37.   // keys there are to avoid on update.  Meaning that key
  38.   // groupins on rows must be mutually unique as a set ?
  39.   // Not sure that the above means aside from a,b and a,c
  40.   // were a b and c are unique would cost unintended results
  41.   // as a,b would be updated by a,c but retain a,b keys
  42.   function insertOrUpdate(knex, tableName, data, fields, uniques) {
  43.     const exclusions = Object.keys(data)
  44.       .filter(c => uniques.indexOf(c) < 0)
  45.       .map(c => knex.raw("?? = EXCLUDED.??", [c, c]).toString())
  46.       .join(",\n");
  47.  
  48.     const insertString = knex(tableName)
  49.       .insert(data)
  50.       .toString();
  51.  
  52.     let conflictString = "";
  53.  
  54.     // If we have uniques && we have non uniques ... yes, this can happen :D
  55.     const nonUniques = fields.filter(f => uniques.indexOf(f) < 0).length;
  56.     if (nonUniques) {
  57.       conflictString = knex
  58.         .raw(
  59.           ` ON CONFLICT (??) DO UPDATE SET ${exclusions} RETURNING *;`,
  60.           uniques.join(", ")
  61.         )
  62.         .toString();
  63.     } else {
  64.       conflictString = knex.raw(` ON CONFLICT DO NOTHING;`).toString();
  65.     }
  66.  
  67.     const query = (insertString + conflictString).replace(/\?/g, "\\?");
  68.  
  69.     return knex.raw(query);
  70.   }
  71.  
  72.   // This is the main function where seeds the database.  Its not the
  73.   // most apt naming.  'silent' is a last minute addition that
  74.   // automatically downloads data and seeds using all shapefiles.
  75.   const runMigrationWith = async (
  76.     zipfile,
  77.     insertTableName,
  78.     migration,
  79.     statecode
  80.   ) => {
  81.     if (
  82.       !silent &&
  83.       (await prompts({
  84.         type: "toggle",
  85.         name: "value",
  86.         message: `Process ${insertTableName} for ${zipfile}`,
  87.         initial: false,
  88.         active: "yes",
  89.         inactive: "no"
  90.       })).value === false
  91.     ) {
  92.       return;
  93.     }
  94.  
  95.     const dropboxPath = zipfile.replace(/data/, "");
  96.     const folderPath = /(.*(?:\/|\\)).*/.exec(zipfile)[1];
  97.     const filename = /.*(?:\/|\\)(.*)/.exec(zipfile)[1];
  98.  
  99.     // Download source files again
  100.     if (downloadFilesAgain) {
  101.       await fsPromises.mkdir(folderPath, { recursive: true });
  102.  
  103.       console.log(`Downloading ${filename}`);
  104.  
  105.       await new Promise(function(resolve, reject) {
  106.         dropstream
  107.           .createDropboxDownloadStream({
  108.             token: dropboxAccessToken,
  109.             path: dropboxPath
  110.           })
  111.           .on("error", err => {
  112.             console.log(err);
  113.             reject(err);
  114.           })
  115.           .on("metadata", metadata => (meta = metadata))
  116.           .pipe(fs.createWriteStream(zipfile))
  117.           .on("finish", () => {
  118.             console.log("Done!");
  119.             resolve(true);
  120.           });
  121.       });
  122.  
  123.       console.log(`Decompressing ${filename}`);
  124.       //require('child_process').execSync(`cd ${folderPath} && unzip -o ${filename}`, (err, stdout, stderr) => {
  125.       // Drop errors
  126.       //});
  127.       console.log("Done!");
  128.     }
  129.  
  130.     const insertion = {};
  131.     let zipEntries = null;
  132.     await new Promise((resolve, reject) => {
  133.       exec(`cd ${folderPath} && unzip -l ${filename}`, (err, stdout, stderr) => {
  134.         resolve(stdout);
  135.       });
  136.     })
  137.       .then(data => (zipEntries = data))
  138.       .catch(err => console.error(err));
  139.     console.log("got zipEntries", zipEntries);
  140.     const shpRegex = /([^\s]+\.shp)$/gm;
  141.     let shpFiles = [];
  142.  
  143.     // Go through all the files in the zip
  144.     let match;
  145.     while ((match = shpRegex.exec(zipEntries))) {
  146.       const zipEntry = match[1];
  147.  
  148.       if (!zipEntry.startsWith("__MAC")) {
  149.         // Do not want these __MAC things
  150.         shpFiles.push(zipEntry);
  151.       }
  152.     }
  153.  
  154.     // Sort to ensure order
  155.     shpFiles = shpFiles.sort();
  156.  
  157.     for (let iZipEntry = 0; iZipEntry < shpFiles.length; iZipEntry++) {
  158.       const zipEntry = shpFiles[iZipEntry];
  159.       const safeEntryName = zipEntry.replace(/(\.|\/|\\)/g, "_");
  160.  
  161.       // Ask to seed. Useful incase we are just seeding bits and pieces
  162.       if (
  163.         silent ||
  164.         (await prompts({
  165.           type: "toggle",
  166.           name: "value",
  167.           message: `Seed ${insertTableName} with ${zipEntry}`,
  168.           initial: false,
  169.           active: "yes",
  170.           inactive: "no"
  171.         })).value === true
  172.       ) {
  173.         console.log(`Processing ${zipEntry}`);
  174.         writeToFile(`Processing ZIPENTRY: ${zipEntry}\n`);
  175.  
  176.         console.log('opening source');
  177.         writeToFile('opening source\n');
  178.         writeToFile(`Opening FolderPath and ZipEntry: ${folderPath} ${zipEntry}\n`);
  179.         const source = await shapefile.open(path.join(folderPath, zipEntry));
  180.         console.log('processing source');        
  181.         writeToFile(`Processing Source: ${source}\n`);
  182.         const fieldMapping = fieldMaps[safeEntryName];
  183.         const relationMapping = relationMaps[safeEntryName];
  184.         if (!fieldMapping) continue; // We did not map this, so skip it :D
  185.  
  186.         let result = await source.read(); // reads each feature in the shapefile
  187.         console.log('init source read');
  188.         writeToFile(`init source read\n`);
  189.         do {
  190.           try {
  191.             let validInsertion = true;
  192.             for (let fieldName in fieldMapping) {
  193.                 console.log(`FN: ${fieldName}`);
  194.                 writeToFile(`FN: ${fieldName}\n`);
  195.  
  196.               // Special case, geometry
  197.               if (fieldName === "geom") {
  198.                 const geojson = JSON.stringify(result.value.geometry);
  199.  
  200.                 /*
  201.                   // The insertion will be deemed invalid if there is unsupported geometry
  202.                   if (/(line|point|collection)/gi.test(geojson)) {
  203.                     validInsertion = false;
  204.                   } else
  205.                 */
  206.                 {
  207.                   insertion[fieldName] = knex.raw(
  208.                     `ST_SetSRID(ST_MakeValid(ST_GeomFromGeoJSON('${geojson}')), 4326)`
  209.                   );
  210.                 }
  211.               }
  212.               // Special case, uuid
  213.               else if (fieldName === "uuid") {
  214.                 insertion[fieldName] = uuidv4();
  215.               }
  216.               // Special case shape_area
  217.               else if (fieldName === "shape_area") {
  218.                 if (fieldMapping[fieldName] === "") {
  219.                   insertion[fieldName] = turf.area(result.value.geometry);
  220.                 }
  221.               }
  222.               // Special case, county if not directly specified
  223.               else if (fieldName === "county") {
  224.                 if (fieldMapping[fieldName] === "") {
  225.                   const maria = /\/Parcels_(.*)_Co/.exec(zipEntry); // naming convention 1
  226.                   const loveland = /\w{2}_(.*)\./.exec(zipEntry); // naming convention 2
  227.                   if (maria && maria.length > 1) {
  228.                     insertion[fieldName] = maria[1].toLowerCase();
  229.                   } else if (loveland && loveland.length > 1) {
  230.                     insertion[fieldName] = loveland[1].toLowerCase();
  231.                   }
  232.                 } else {
  233.                   insertion[fieldName] = result.value.properties[
  234.                     fieldMapping[fieldName]
  235.                   ].toLowerCase();
  236.                 }
  237.               }
  238.               // Special case, state if not directly specified
  239.               else if (fieldName === "state" && fieldMapping[fieldName] === "") {
  240.                 insertion[fieldName] = statecode.toUpperCase();
  241.               }
  242.               // Special case, any field that is also denoted by "referecnes"
  243.               else if (
  244.                 migration.references &&
  245.                 fieldName in migration.references
  246.               ) {
  247.                 // This is a refernec e so we need to go the extra mile
  248.                 const refTable = /(.*)\./.exec(
  249.                   migration.references[fieldName]
  250.                 )[1];
  251.                 const ref = /.*\.(.*)/.exec(migration.references[fieldName])[1];
  252.  
  253.                 const condition = {};
  254.                 condition[relationMapping[fieldName]] =
  255.                   result.value.properties[fieldMapping[fieldName]];
  256.  
  257.                 // Try to find an existing match
  258.                 let r = await knex(refTable)
  259.                   .select(ref)
  260.                   .where(condition);
  261.  
  262.                 // If there is not linking element, we insert one that satisfies our conditions
  263.                 if (!r.length) {
  264.                   //  console.log("inserting");
  265.                   let q = await knex(refTable).insert(condition);
  266.                   //  console.log(q);
  267.  
  268.                   r = await knex(refTable)
  269.                     .select(ref)
  270.                     .where(condition);
  271.                 }
  272.  
  273.                 insertion[fieldName] = r[0][ref];
  274.               }
  275.               // Otherwise we map if none is provided
  276.               else if (
  277.                 fieldMapping[fieldName] !== "" &&
  278.                 fieldMapping[fieldName] !== "NONE" &&
  279.                 result.value.properties // for when the dbf exceeds the max size of 2.15GB and we literally run out of data ... :(
  280.               ) {
  281.                 insertion[fieldName] =
  282.                   result.value.properties[fieldMapping[fieldName]];
  283.               }
  284.  
  285.               // Unit conversion
  286.               if (fieldMapping[fieldName].toLowerCase().indexOf("acre") >= 0) {
  287.                 insertion[fieldName] = 4046.86 * insertion[fieldName];
  288.               } else if (
  289.                 fieldMapping[fieldName].toLowerCase().indexOf("sqft") >= 0
  290.               ) {
  291.                 insertion[fieldName] = 0.092903 * insertion[fieldName];
  292.               }
  293.             }
  294.             let cache = [];
  295.             // console.log(JSON.stringify(insertion, function(key, value) {
  296.             //   if (typeof value === 'object' && value !== null) {
  297.             //       if (cache.indexOf(value) !== -1) {
  298.             //           // Duplicate reference found
  299.             //           try {
  300.             //               // If this value does not reference a parent it can be deduped
  301.             //               return JSON.parse(JSON.stringify(value));
  302.             //           } catch (error) {
  303.             //               // discard key if value cannot be deduped
  304.             //               return;
  305.             //           }
  306.             //       }
  307.             //       // Store value in our collection
  308.             //       cache.push(value);
  309.             //   }
  310.             //   return value;
  311.             // }));
  312.             // console.log(insertion.pid);
  313.  
  314.             if (validInsertion) {
  315.                 console.log('start valid insertion');
  316.                 writeToFile('start valid insertion\n');
  317.               // If we have uniques && we have non uniques ... yes, this can happen :D
  318.               if (migration.uniques) {
  319.                   console.log('insert or update');
  320.                 await insertOrUpdate(
  321.                   knex,
  322.                   insertTableName,
  323.                   insertion,
  324.                   migration.fields,
  325.                   migration.uniques
  326.                 );
  327.               } else {
  328.                 console.log('normal insert');
  329.                 writeToFile('normal insert\n');
  330.                 await knex(insertTableName).insert(insertion);
  331.               }
  332.               console.log('valid insertion');
  333.               writeToFile('valid insertion\n');
  334.             }
  335.           } catch (e) {
  336.             console.log("Error inserting: " + insertion.oid);
  337.             console.log(e.message);
  338.           } finally {
  339.             console.log(`Processing ${zipEntry}`);
  340.             writeToFile(`Processing ${zipEntry}\n`);
  341.             result = await source.read();
  342.             console.log('finally result source read');
  343.             writeToFile('finally result source read\n');
  344.            
  345.           }
  346.         } while (!result.done);
  347.       }
  348.     }
  349.   };
  350.  
  351.   (async function() {
  352.     downloadFilesAgain =
  353.       silent ||
  354.       (await prompts({
  355.         type: "toggle",
  356.         name: "value",
  357.         message: `Fetch new data from dropbox?`,
  358.         initial: false,
  359.         active: "yes",
  360.         inactive: "no"
  361.       })).value;
  362.     if ((await knex.schema.hasTable("parcels")) == false) {
  363.       await knex.schema.createTable("parcels", function(table) {
  364.         table.increments("id");
  365.         table
  366.           .uuid("uuid")
  367.           .index()
  368.           .unique()
  369.           .notNullable();
  370.         table.integer("oid").index();
  371.         table.text("pid");
  372.         table.text("county");
  373.         table.decimal("assessed_area", 14, 2);
  374.         table.decimal("shape_area", 14, 2);
  375.         table.text("state").index();
  376.         table.specificType("geom", "geometry").index(null, "GIST");
  377.         table.jsonb("cache");
  378.         table.datetime("deleted_at");
  379.         table.timestamps(true, true);
  380.       });
  381.     }
  382.     fieldMaps["Parcels_Fl_fl_duval_shp"] = {
  383.       uuid: "",
  384.       oid: "geoid",
  385.       pid: "parcelnumb",
  386.       county: "county",
  387.       assessed_area: "",
  388.       shape_area: "",
  389.       state: "sourceagen",
  390.       geom: ""
  391.     };
  392.     relationMaps["Parcels_Fl_fl_duval_shp"] = {};
  393.     fieldMaps["Parcels_Fl_fl_hardee_shp"] = {
  394.       uuid: "",
  395.       oid: "geoid",
  396.       pid: "parcelnumb",
  397.       county: "county",
  398.       assessed_area: "",
  399.       shape_area: "",
  400.       state: "sourceagen",
  401.       geom: ""
  402.     };
  403.     relationMaps["Parcels_Fl_fl_hardee_shp"] = {};
  404.     fieldMaps["Parcels_Fl_fl_gadsden_shp"] = {
  405.       uuid: "",
  406.       oid: "geoid",
  407.       pid: "parcelnumb",
  408.       county: "county",
  409.       assessed_area: "",
  410.       shape_area: "",
  411.       state: "sourceagen",
  412.       geom: ""
  413.     };
  414.     relationMaps["Parcels_Fl_fl_gadsden_shp"] = {};
  415.     fieldMaps["Parcels_Fl_fl_lafayette_shp"] = {
  416.       uuid: "",
  417.       oid: "geoid",
  418.       pid: "parcelnumb",
  419.       county: "county",
  420.       assessed_area: "",
  421.       shape_area: "",
  422.       state: "sourceagen",
  423.       geom: ""
  424.     };
  425.     relationMaps["Parcels_Fl_fl_lafayette_shp"] = {};
  426.     fieldMaps["Parcels_Fl_fl_calhoun_shp"] = {
  427.       uuid: "",
  428.       oid: "geoid",
  429.       pid: "parcelnumb",
  430.       county: "county",
  431.       assessed_area: "",
  432.       shape_area: "",
  433.       state: "sourceagen",
  434.       geom: ""
  435.     };
  436.     relationMaps["Parcels_Fl_fl_calhoun_shp"] = {};
  437.     fieldMaps["Parcels_Fl_fl_miami-dade_shp"] = {
  438.       uuid: "",
  439.       oid: "geoid",
  440.       pid: "parcelnumb",
  441.       county: "county",
  442.       assessed_area: "",
  443.       shape_area: "",
  444.       state: "sourceagen",
  445.       geom: ""
  446.     };
  447.     relationMaps["Parcels_Fl_fl_miami-dade_shp"] = {};
  448.     fieldMaps["Parcels_Fl_fl_orange_shp"] = {
  449.       uuid: "",
  450.       oid: "geoid",
  451.       pid: "parcelnumb",
  452.       county: "county",
  453.       assessed_area: "",
  454.       shape_area: "",
  455.       state: "sourceagen",
  456.       geom: ""
  457.     };
  458.     relationMaps["Parcels_Fl_fl_orange_shp"] = {};
  459.     fieldMaps["Parcels_Fl_fl_volusia_shp"] = {
  460.       uuid: "",
  461.       oid: "geoid",
  462.       pid: "parcelnumb",
  463.       county: "county",
  464.       assessed_area: "",
  465.       shape_area: "",
  466.       state: "sourceagen",
  467.       geom: ""
  468.     };
  469.     relationMaps["Parcels_Fl_fl_volusia_shp"] = {};
  470.     fieldMaps["Parcels_Fl_fl_brevard_shp"] = {
  471.       uuid: "",
  472.       oid: "geoid",
  473.       pid: "parcelnumb",
  474.       county: "county",
  475.       assessed_area: "",
  476.       shape_area: "",
  477.       state: "sourceagen",
  478.       geom: ""
  479.     };
  480.     relationMaps["Parcels_Fl_fl_brevard_shp"] = {};
  481.     fieldMaps["Parcels_Fl_fl_bradford_shp"] = {
  482.       uuid: "",
  483.       oid: "geoid",
  484.       pid: "parcelnumb",
  485.       county: "county",
  486.       assessed_area: "",
  487.       shape_area: "",
  488.       state: "sourceagen",
  489.       geom: ""
  490.     };
  491.     relationMaps["Parcels_Fl_fl_bradford_shp"] = {};
  492.     fieldMaps["Parcels_Fl_fl_santa-rosa_shp"] = {
  493.       uuid: "",
  494.       oid: "geoid",
  495.       pid: "parcelnumb",
  496.       county: "county",
  497.       assessed_area: "",
  498.       shape_area: "",
  499.       state: "sourceagen",
  500.       geom: ""
  501.     };
  502.     relationMaps["Parcels_Fl_fl_santa-rosa_shp"] = {};
  503.     fieldMaps["Parcels_Fl_fl_franklin_shp"] = {
  504.       uuid: "",
  505.       oid: "geoid",
  506.       pid: "parcelnumb",
  507.       county: "county",
  508.       assessed_area: "",
  509.       shape_area: "",
  510.       state: "sourceagen",
  511.       geom: ""
  512.     };
  513.     relationMaps["Parcels_Fl_fl_franklin_shp"] = {};
  514.     fieldMaps["Parcels_Fl_fl_sarasota_shp"] = {
  515.       uuid: "",
  516.       oid: "geoid",
  517.       pid: "parcelnumb",
  518.       county: "county",
  519.       assessed_area: "",
  520.       shape_area: "",
  521.       state: "sourceagen",
  522.       geom: ""
  523.     };
  524.     relationMaps["Parcels_Fl_fl_sarasota_shp"] = {};
  525.     fieldMaps["Parcels_Fl_fl_gilchrist_shp"] = {
  526.       uuid: "",
  527.       oid: "geoid",
  528.       pid: "parcelnumb",
  529.       county: "county",
  530.       assessed_area: "",
  531.       shape_area: "",
  532.       state: "sourceagen",
  533.       geom: ""
  534.     };
  535.     relationMaps["Parcels_Fl_fl_gilchrist_shp"] = {};
  536.     fieldMaps["Parcels_Fl_fl_manatee_shp"] = {
  537.       uuid: "",
  538.       oid: "geoid",
  539.       pid: "parcelnumb",
  540.       county: "county",
  541.       assessed_area: "",
  542.       shape_area: "",
  543.       state: "sourceagen",
  544.       geom: ""
  545.     };
  546.     relationMaps["Parcels_Fl_fl_manatee_shp"] = {};
  547.     fieldMaps["Parcels_Fl_fl_jackson_shp"] = {
  548.       uuid: "",
  549.       oid: "geoid",
  550.       pid: "parcelnumb",
  551.       county: "county",
  552.       assessed_area: "",
  553.       shape_area: "",
  554.       state: "sourceagen",
  555.       geom: ""
  556.     };
  557.     relationMaps["Parcels_Fl_fl_jackson_shp"] = {};
  558.     fieldMaps["Parcels_Fl_fl_liberty_shp"] = {
  559.       uuid: "",
  560.       oid: "geoid",
  561.       pid: "parcelnumb",
  562.       county: "county",
  563.       assessed_area: "",
  564.       shape_area: "",
  565.       state: "sourceagen",
  566.       geom: ""
  567.     };
  568.     relationMaps["Parcels_Fl_fl_liberty_shp"] = {};
  569.     fieldMaps["Parcels_Fl_fl_bay_shp"] = {
  570.       uuid: "",
  571.       oid: "geoid",
  572.       pid: "parcelnumb",
  573.       county: "county",
  574.       assessed_area: "",
  575.       shape_area: "",
  576.       state: "sourceagen",
  577.       geom: ""
  578.     };
  579.     relationMaps["Parcels_Fl_fl_bay_shp"] = {};
  580.     fieldMaps["Parcels_Fl_fl_holmes_shp"] = {
  581.       uuid: "",
  582.       oid: "geoid",
  583.       pid: "parcelnumb",
  584.       county: "county",
  585.       assessed_area: "",
  586.       shape_area: "",
  587.       state: "sourceagen",
  588.       geom: ""
  589.     };
  590.     relationMaps["Parcels_Fl_fl_holmes_shp"] = {};
  591.     fieldMaps["Parcels_Fl_fl_washington_shp"] = {
  592.       uuid: "",
  593.       oid: "geoid",
  594.       pid: "parcelnumb",
  595.       county: "county",
  596.       assessed_area: "",
  597.       shape_area: "",
  598.       state: "sourceagen",
  599.       geom: ""
  600.     };
  601.     relationMaps["Parcels_Fl_fl_washington_shp"] = {};
  602.     fieldMaps["Parcels_Fl_fl_hillsborough_shp"] = {
  603.       uuid: "",
  604.       oid: "geoid",
  605.       pid: "parcelnumb",
  606.       county: "county",
  607.       assessed_area: "",
  608.       shape_area: "",
  609.       state: "sourceagen",
  610.       geom: ""
  611.     };
  612.     relationMaps["Parcels_Fl_fl_hillsborough_shp"] = {};
  613.     fieldMaps["Parcels_Fl_fl_hernando_shp"] = {
  614.       uuid: "",
  615.       oid: "geoid",
  616.       pid: "parcelnumb",
  617.       county: "county",
  618.       assessed_area: "",
  619.       shape_area: "",
  620.       state: "sourceagen",
  621.       geom: ""
  622.     };
  623.     relationMaps["Parcels_Fl_fl_hernando_shp"] = {};
  624.     fieldMaps["Parcels_Fl_fl_levy_shp"] = {
  625.       uuid: "",
  626.       oid: "geoid",
  627.       pid: "parcelnumb",
  628.       county: "county",
  629.       assessed_area: "",
  630.       shape_area: "",
  631.       state: "sourceagen",
  632.       geom: ""
  633.     };
  634.     relationMaps["Parcels_Fl_fl_levy_shp"] = {};
  635.     fieldMaps["Parcels_Fl_fl_martin_shp"] = {
  636.       uuid: "",
  637.       oid: "geoid",
  638.       pid: "parcelnumb",
  639.       county: "county",
  640.       assessed_area: "",
  641.       shape_area: "",
  642.       state: "sourceagen",
  643.       geom: ""
  644.     };
  645.     relationMaps["Parcels_Fl_fl_martin_shp"] = {};
  646.     fieldMaps["Parcels_Fl_fl_sumter_shp"] = {
  647.       uuid: "",
  648.       oid: "geoid",
  649.       pid: "parcelnumb",
  650.       county: "county",
  651.       assessed_area: "",
  652.       shape_area: "",
  653.       state: "sourceagen",
  654.       geom: ""
  655.     };
  656.     relationMaps["Parcels_Fl_fl_sumter_shp"] = {};
  657.     fieldMaps["Parcels_Fl_fl_citrus_shp"] = {
  658.       uuid: "",
  659.       oid: "geoid",
  660.       pid: "parcelnumb",
  661.       county: "county",
  662.       assessed_area: "",
  663.       shape_area: "",
  664.       state: "sourceagen",
  665.       geom: ""
  666.     };
  667.     relationMaps["Parcels_Fl_fl_citrus_shp"] = {};
  668.     fieldMaps["Parcels_Fl_fl_clay_shp"] = {
  669.       uuid: "",
  670.       oid: "geoid",
  671.       pid: "parcelnumb",
  672.       county: "county",
  673.       assessed_area: "",
  674.       shape_area: "",
  675.       state: "sourceagen",
  676.       geom: ""
  677.     };
  678.     relationMaps["Parcels_Fl_fl_clay_shp"] = {};
  679.     fieldMaps["Parcels_Fl_fl_columbia_shp"] = {
  680.       uuid: "",
  681.       oid: "geoid",
  682.       pid: "parcelnumb",
  683.       county: "county",
  684.       assessed_area: "",
  685.       shape_area: "",
  686.       state: "sourceagen",
  687.       geom: ""
  688.     };
  689.     relationMaps["Parcels_Fl_fl_columbia_shp"] = {};
  690.     fieldMaps["Parcels_Fl_fl_seminole_shp"] = {
  691.       uuid: "",
  692.       oid: "geoid",
  693.       pid: "parcelnumb",
  694.       county: "county",
  695.       assessed_area: "",
  696.       shape_area: "",
  697.       state: "sourceagen",
  698.       geom: ""
  699.     };
  700.     relationMaps["Parcels_Fl_fl_seminole_shp"] = {};
  701.     fieldMaps["Parcels_Fl_fl_alachua_shp"] = {
  702.       uuid: "",
  703.       oid: "geoid",
  704.       pid: "parcelnumb",
  705.       county: "county",
  706.       assessed_area: "",
  707.       shape_area: "",
  708.       state: "sourceagen",
  709.       geom: ""
  710.     };
  711.     relationMaps["Parcels_Fl_fl_alachua_shp"] = {};
  712.     fieldMaps["Parcels_Fl_fl_walton_shp"] = {
  713.       uuid: "",
  714.       oid: "geoid",
  715.       pid: "parcelnumb",
  716.       county: "county",
  717.       assessed_area: "",
  718.       shape_area: "",
  719.       state: "sourceagen",
  720.       geom: ""
  721.     };
  722.     relationMaps["Parcels_Fl_fl_walton_shp"] = {};
  723.     fieldMaps["Parcels_Fl_fl_jefferson_shp"] = {
  724.       uuid: "",
  725.       oid: "geoid",
  726.       pid: "parcelnumb",
  727.       county: "county",
  728.       assessed_area: "",
  729.       shape_area: "",
  730.       state: "sourceagen",
  731.       geom: ""
  732.     };
  733.     relationMaps["Parcels_Fl_fl_jefferson_shp"] = {};
  734.     fieldMaps["Parcels_Fl_fl_st-johns_shp"] = {
  735.       uuid: "",
  736.       oid: "geoid",
  737.       pid: "parcelnumb",
  738.       county: "county",
  739.       assessed_area: "",
  740.       shape_area: "",
  741.       state: "sourceagen",
  742.       geom: ""
  743.     };
  744.     relationMaps["Parcels_Fl_fl_st-johns_shp"] = {};
  745.     fieldMaps["Parcels_Fl_fl_leon_shp"] = {
  746.       uuid: "",
  747.       oid: "geoid",
  748.       pid: "parcelnumb",
  749.       county: "county",
  750.       assessed_area: "",
  751.       shape_area: "",
  752.       state: "sourceagen",
  753.       geom: ""
  754.     };
  755.     relationMaps["Parcels_Fl_fl_leon_shp"] = {};
  756.     fieldMaps["Parcels_Fl_fl_pasco_shp"] = {
  757.       uuid: "",
  758.       oid: "geoid",
  759.       pid: "parcelnumb",
  760.       county: "county",
  761.       assessed_area: "",
  762.       shape_area: "",
  763.       state: "sourceagen",
  764.       geom: ""
  765.     };
  766.     relationMaps["Parcels_Fl_fl_pasco_shp"] = {};
  767.     fieldMaps["Parcels_Fl_fl_okaloosa_shp"] = {
  768.       uuid: "",
  769.       oid: "geoid",
  770.       pid: "parcelnumb",
  771.       county: "county",
  772.       assessed_area: "",
  773.       shape_area: "",
  774.       state: "sourceagen",
  775.       geom: ""
  776.     };
  777.     relationMaps["Parcels_Fl_fl_okaloosa_shp"] = {};
  778.     fieldMaps["Parcels_Fl_fl_wakulla_shp"] = {
  779.       uuid: "",
  780.       oid: "geoid",
  781.       pid: "parcelnumb",
  782.       county: "county",
  783.       assessed_area: "",
  784.       shape_area: "",
  785.       state: "sourceagen",
  786.       geom: ""
  787.     };
  788.     relationMaps["Parcels_Fl_fl_wakulla_shp"] = {};
  789.     fieldMaps["Parcels_Fl_fl_union_shp"] = {
  790.       uuid: "",
  791.       oid: "geoid",
  792.       pid: "parcelnumb",
  793.       county: "county",
  794.       assessed_area: "",
  795.       shape_area: "",
  796.       state: "sourceagen",
  797.       geom: ""
  798.     };
  799.     relationMaps["Parcels_Fl_fl_union_shp"] = {};
  800.     fieldMaps["Parcels_Fl_fl_charlotte_shp"] = {
  801.       uuid: "",
  802.       oid: "geoid",
  803.       pid: "parcelnumb",
  804.       county: "county",
  805.       assessed_area: "",
  806.       shape_area: "",
  807.       state: "sourceagen",
  808.       geom: ""
  809.     };
  810.     relationMaps["Parcels_Fl_fl_charlotte_shp"] = {};
  811.     fieldMaps["Parcels_Fl_fl_suwannee_shp"] = {
  812.       uuid: "",
  813.       oid: "geoid",
  814.       pid: "parcelnumb",
  815.       county: "county",
  816.       assessed_area: "",
  817.       shape_area: "",
  818.       state: "sourceagen",
  819.       geom: ""
  820.     };
  821.     relationMaps["Parcels_Fl_fl_suwannee_shp"] = {};
  822.     fieldMaps["Parcels_Fl_fl_hendry_shp"] = {
  823.       uuid: "",
  824.       oid: "geoid",
  825.       pid: "parcelnumb",
  826.       county: "county",
  827.       assessed_area: "",
  828.       shape_area: "",
  829.       state: "sourceagen",
  830.       geom: ""
  831.     };
  832.     relationMaps["Parcels_Fl_fl_hendry_shp"] = {};
  833.     fieldMaps["Parcels_Fl_fl_indian-river_shp"] = {
  834.       uuid: "",
  835.       oid: "geoid",
  836.       pid: "parcelnumb",
  837.       county: "county",
  838.       assessed_area: "",
  839.       shape_area: "",
  840.       state: "sourceagen",
  841.       geom: ""
  842.     };
  843.     relationMaps["Parcels_Fl_fl_indian-river_shp"] = {};
  844.     fieldMaps["Parcels_Fl_fl_nassau_shp"] = {
  845.       uuid: "",
  846.       oid: "geoid",
  847.       pid: "parcelnumb",
  848.       county: "county",
  849.       assessed_area: "",
  850.       shape_area: "",
  851.       state: "sourceagen",
  852.       geom: ""
  853.     };
  854.     relationMaps["Parcels_Fl_fl_nassau_shp"] = {};
  855.     fieldMaps["Parcels_Fl_fl_putnam_shp"] = {
  856.       uuid: "",
  857.       oid: "geoid",
  858.       pid: "parcelnumb",
  859.       county: "county",
  860.       assessed_area: "",
  861.       shape_area: "",
  862.       state: "sourceagen",
  863.       geom: ""
  864.     };
  865.     relationMaps["Parcels_Fl_fl_putnam_shp"] = {};
  866.     fieldMaps["Parcels_Fl_fl_broward_shp"] = {
  867.       uuid: "",
  868.       oid: "geoid",
  869.       pid: "parcelnumb",
  870.       county: "county",
  871.       assessed_area: "",
  872.       shape_area: "",
  873.       state: "sourceagen",
  874.       geom: ""
  875.     };
  876.     relationMaps["Parcels_Fl_fl_broward_shp"] = {};
  877.     fieldMaps["Parcels_Fl_fl_dixie_shp"] = {
  878.       uuid: "",
  879.       oid: "geoid",
  880.       pid: "parcelnumb",
  881.       county: "county",
  882.       assessed_area: "",
  883.       shape_area: "",
  884.       state: "sourceagen",
  885.       geom: ""
  886.     };
  887.     relationMaps["Parcels_Fl_fl_dixie_shp"] = {};
  888.     fieldMaps["Parcels_Fl_fl_taylor_shp"] = {
  889.       uuid: "",
  890.       oid: "geoid",
  891.       pid: "parcelnumb",
  892.       county: "county",
  893.       assessed_area: "",
  894.       shape_area: "",
  895.       state: "sourceagen",
  896.       geom: ""
  897.     };
  898.     relationMaps["Parcels_Fl_fl_taylor_shp"] = {};
  899.     fieldMaps["Parcels_Fl_fl_osceola_shp"] = {
  900.       uuid: "",
  901.       oid: "geoid",
  902.       pid: "parcelnumb",
  903.       county: "county",
  904.       assessed_area: "",
  905.       shape_area: "",
  906.       state: "sourceagen",
  907.       geom: ""
  908.     };
  909.     relationMaps["Parcels_Fl_fl_osceola_shp"] = {};
  910.     fieldMaps["Parcels_Fl_fl_pinellas_shp"] = {
  911.       uuid: "",
  912.       oid: "geoid",
  913.       pid: "parcelnumb",
  914.       county: "county",
  915.       assessed_area: "",
  916.       shape_area: "",
  917.       state: "sourceagen",
  918.       geom: ""
  919.     };
  920.     relationMaps["Parcels_Fl_fl_pinellas_shp"] = {};
  921.     fieldMaps["Parcels_Fl_fl_flagler_shp"] = {
  922.       uuid: "",
  923.       oid: "geoid",
  924.       pid: "parcelnumb",
  925.       county: "county",
  926.       assessed_area: "",
  927.       shape_area: "",
  928.       state: "sourceagen",
  929.       geom: ""
  930.     };
  931.     relationMaps["Parcels_Fl_fl_flagler_shp"] = {};
  932.     fieldMaps["Parcels_Fl_fl_monroe_shp"] = {
  933.       uuid: "",
  934.       oid: "geoid",
  935.       pid: "parcelnumb",
  936.       county: "county",
  937.       assessed_area: "",
  938.       shape_area: "",
  939.       state: "sourceagen",
  940.       geom: ""
  941.     };
  942.     relationMaps["Parcels_Fl_fl_monroe_shp"] = {};
  943.     fieldMaps["Parcels_Fl_fl_palm_beach_shp"] = {
  944.       uuid: "",
  945.       oid: "geoid",
  946.       pid: "parcelnumb",
  947.       county: "county",
  948.       assessed_area: "",
  949.       shape_area: "",
  950.       state: "sourceagen",
  951.       geom: ""
  952.     };
  953.     relationMaps["Parcels_Fl_fl_palm_beach_shp"] = {};
  954.     fieldMaps["Parcels_Fl_fl_glades_shp"] = {
  955.       uuid: "",
  956.       oid: "geoid",
  957.       pid: "parcelnumb",
  958.       county: "county",
  959.       assessed_area: "",
  960.       shape_area: "",
  961.       state: "sourceagen",
  962.       geom: ""
  963.     };
  964.     relationMaps["Parcels_Fl_fl_glades_shp"] = {};
  965.     fieldMaps["Parcels_Fl_fl_baker_shp"] = {
  966.       uuid: "",
  967.       oid: "geoid",
  968.       pid: "parcelnumb",
  969.       county: "county",
  970.       assessed_area: "",
  971.       shape_area: "",
  972.       state: "sourceagen",
  973.       geom: ""
  974.     };
  975.     relationMaps["Parcels_Fl_fl_baker_shp"] = {};
  976.     fieldMaps["Parcels_Fl_fl_highlands_shp"] = {
  977.       uuid: "",
  978.       oid: "geoid",
  979.       pid: "parcelnumb",
  980.       county: "county",
  981.       assessed_area: "",
  982.       shape_area: "",
  983.       state: "sourceagen",
  984.       geom: ""
  985.     };
  986.     relationMaps["Parcels_Fl_fl_highlands_shp"] = {};
  987.     fieldMaps["Parcels_Fl_fl_marion_shp"] = {
  988.       uuid: "",
  989.       oid: "geoid",
  990.       pid: "parcelnumb",
  991.       county: "county",
  992.       assessed_area: "",
  993.       shape_area: "",
  994.       state: "sourceagen",
  995.       geom: ""
  996.     };
  997.     relationMaps["Parcels_Fl_fl_marion_shp"] = {};
  998.     fieldMaps["Parcels_Fl_fl_lee_shp"] = {
  999.       uuid: "",
  1000.       oid: "geoid",
  1001.       pid: "parcelnumb",
  1002.       county: "county",
  1003.       assessed_area: "",
  1004.       shape_area: "",
  1005.       state: "sourceagen",
  1006.       geom: ""
  1007.     };
  1008.     relationMaps["Parcels_Fl_fl_lee_shp"] = {};
  1009.     fieldMaps["Parcels_Fl_fl_escambia_shp"] = {
  1010.       uuid: "",
  1011.       oid: "geoid",
  1012.       pid: "parcelnumb",
  1013.       county: "county",
  1014.       assessed_area: "",
  1015.       shape_area: "",
  1016.       state: "sourceagen",
  1017.       geom: ""
  1018.     };
  1019.     relationMaps["Parcels_Fl_fl_escambia_shp"] = {};
  1020.     fieldMaps["Parcels_Fl_fl_okeechobee_shp"] = {
  1021.       uuid: "",
  1022.       oid: "geoid",
  1023.       pid: "parcelnumb",
  1024.       county: "county",
  1025.       assessed_area: "",
  1026.       shape_area: "",
  1027.       state: "sourceagen",
  1028.       geom: ""
  1029.     };
  1030.     relationMaps["Parcels_Fl_fl_okeechobee_shp"] = {};
  1031.     fieldMaps["Parcels_Fl_fl_desoto_shp"] = {
  1032.       uuid: "",
  1033.       oid: "geoid",
  1034.       pid: "parcelnumb",
  1035.       county: "county",
  1036.       assessed_area: "",
  1037.       shape_area: "",
  1038.       state: "sourceagen",
  1039.       geom: ""
  1040.     };
  1041.     relationMaps["Parcels_Fl_fl_desoto_shp"] = {};
  1042.     fieldMaps["Parcels_Fl_fl_lake_shp"] = {
  1043.       uuid: "",
  1044.       oid: "geoid",
  1045.       pid: "parcelnumb",
  1046.       county: "county",
  1047.       assessed_area: "",
  1048.       shape_area: "",
  1049.       state: "sourceagen",
  1050.       geom: ""
  1051.     };
  1052.     relationMaps["Parcels_Fl_fl_lake_shp"] = {};
  1053.     fieldMaps["Parcels_Fl_fl_collier_shp"] = {
  1054.       uuid: "",
  1055.       oid: "geoid",
  1056.       pid: "parcelnumb",
  1057.       county: "county",
  1058.       assessed_area: "",
  1059.       shape_area: "",
  1060.       state: "sourceagen",
  1061.       geom: ""
  1062.     };
  1063.     relationMaps["Parcels_Fl_fl_collier_shp"] = {};
  1064.     fieldMaps["Parcels_Fl_fl_polk_shp"] = {
  1065.       uuid: "",
  1066.       oid: "geoid",
  1067.       pid: "parcelnumb",
  1068.       county: "county",
  1069.       assessed_area: "",
  1070.       shape_area: "",
  1071.       state: "sourceagen",
  1072.       geom: ""
  1073.     };
  1074.     relationMaps["Parcels_Fl_fl_polk_shp"] = {};
  1075.     fieldMaps["Parcels_Fl_fl_madison_shp"] = {
  1076.       uuid: "",
  1077.       oid: "geoid",
  1078.       pid: "parcelnumb",
  1079.       county: "county",
  1080.       assessed_area: "",
  1081.       shape_area: "",
  1082.       state: "sourceagen",
  1083.       geom: ""
  1084.     };
  1085.     relationMaps["Parcels_Fl_fl_madison_shp"] = {};
  1086.     fieldMaps["Parcels_Fl_fl_hamilton_shp"] = {
  1087.       uuid: "",
  1088.       oid: "geoid",
  1089.       pid: "parcelnumb",
  1090.       county: "county",
  1091.       assessed_area: "",
  1092.       shape_area: "",
  1093.       state: "sourceagen",
  1094.       geom: ""
  1095.     };
  1096.     relationMaps["Parcels_Fl_fl_hamilton_shp"] = {};
  1097.     fieldMaps["Parcels_Fl_fl_palm-beach_shp"] = {
  1098.       uuid: "",
  1099.       oid: "geoid",
  1100.       pid: "parcelnumb",
  1101.       county: "county",
  1102.       assessed_area: "",
  1103.       shape_area: "",
  1104.       state: "sourceagen",
  1105.       geom: ""
  1106.     };
  1107.     relationMaps["Parcels_Fl_fl_palm-beach_shp"] = {};
  1108.     fieldMaps["Parcels_Fl_fl_st-lucie_shp"] = {
  1109.       uuid: "",
  1110.       oid: "geoid",
  1111.       pid: "parcelnumb",
  1112.       county: "county",
  1113.       assessed_area: "",
  1114.       shape_area: "",
  1115.       state: "sourceagen",
  1116.       geom: ""
  1117.     };
  1118.     relationMaps["Parcels_Fl_fl_st-lucie_shp"] = {};
  1119.     fieldMaps["Parcels_Fl_fl_gulf_shp"] = {
  1120.       uuid: "",
  1121.       oid: "geoid",
  1122.       pid: "parcelnumb",
  1123.       county: "county",
  1124.       assessed_area: "",
  1125.       shape_area: "",
  1126.       state: "sourceagen",
  1127.       geom: ""
  1128.     };
  1129.     relationMaps["Parcels_Fl_fl_gulf_shp"] = {};
  1130.     await runMigrationWith(
  1131.       "data/GIS/gis_processed_data/wc_florida/WC_FL_V0.1/Parcels_Fl.zip",
  1132.       "parcels",
  1133.       {
  1134.         table: "parcels",
  1135.         func:
  1136.           "    await knex.schema.createTable('parcels', function (table) {        table.increments('id');        table.uuid('uuid').index().unique().notNullable();        table.integer('oid').index();        table.text('pid');        table.text('county');        table.decimal('assessed_area', 14, 2);            table.decimal('shape_area', 14, 2);        table.text('state').index();           table.specificType('geom', 'geometry').index(null, 'GIST');        table.jsonb('cache');        table.datetime('deleted_at');        table.timestamps(true, true);    });",
  1137.         fields: [
  1138.           "uuid",
  1139.           "oid",
  1140.           "pid",
  1141.           "county",
  1142.           "assessed_area",
  1143.           "shape_area",
  1144.           "state",
  1145.           "geom"
  1146.         ],
  1147.         references: {},
  1148.         uniques: ["uuid"]
  1149.       },
  1150.       "FL"
  1151.     );
  1152.     if ((await knex.schema.hasTable("fl_forests")) == false) {
  1153.       await knex.schema.createTable("fl_forests", function(table) {
  1154.         table.increments("id");
  1155.         table
  1156.           .uuid("uuid")
  1157.           .index()
  1158.           .unique()
  1159.           .notNullable();
  1160.         table.integer("oid").index();
  1161.         table.integer("value").notNullable();
  1162.         table.specificType("geom", "geometry").index(null, "GIST");
  1163.         table.datetime("deleted_at");
  1164.         table.timestamps(true, true);
  1165.       });
  1166.     }
  1167.     fieldMaps["Forest_FL_Forest_FL_shp"] = {
  1168.       uuid: "",
  1169.       oid: "OBJECTID",
  1170.       value: "SITE",
  1171.       geom: ""
  1172.     };
  1173.     relationMaps["Forest_FL_Forest_FL_shp"] = {};
  1174.     await runMigrationWith(
  1175.       "data/GIS/GIS_Processed_Data/WC_Florida/WC_FL_V0.1/Forest_FL.zip",
  1176.       "fl_forests",
  1177.       {
  1178.         table: "fl_forests",
  1179.         func:
  1180.           "    await knex.schema.createTable('fl_forests', function (table) {        table.increments('id');        table.uuid('uuid').index().unique().notNullable();        table.integer('oid').index();        table.integer('value').notNullable();        table.specificType('geom', 'geometry').index(null, 'GIST');        table.datetime('deleted_at');        table.timestamps(true, true);    });",
  1181.         fields: ["uuid", "oid", "value", "geom"],
  1182.         references: {},
  1183.         uniques: ["uuid"]
  1184.       },
  1185.       "FL"
  1186.     );
  1187.     if ((await knex.schema.hasTable("fl_hurricane_severity")) == false) {
  1188.       await knex.schema.createTable("fl_hurricane_severity", function(table) {
  1189.         table.increments("id");
  1190.         table
  1191.           .uuid("uuid")
  1192.           .index()
  1193.           .unique()
  1194.           .notNullable();
  1195.         table.integer("oid").index();
  1196.         table.specificType("geom", "geometry").index(null, "GIST");
  1197.         table.text("slope");
  1198.         table.datetime("deleted_at");
  1199.         table.timestamps(true, true);
  1200.       });
  1201.     }
  1202.     fieldMaps["Hurricane_Severity_FL_Hurricane_Severity_FL_shp"] = {
  1203.       uuid: "",
  1204.       oid: "",
  1205.       geom: "",
  1206.       slope: ""
  1207.     };
  1208.     relationMaps["Hurricane_Severity_FL_Hurricane_Severity_FL_shp"] = {};
  1209.     await runMigrationWith(
  1210.       "data/GIS/GIS_Processed_Data/WC_Florida/WC_FL_V0.1/Hurricane_Severity_FL.zip",
  1211.       "fl_hurricane_severity",
  1212.       {
  1213.         table: "fl_hurricane_severity",
  1214.         func:
  1215.           "    await knex.schema.createTable('fl_hurricane_severity', function (table) {        table.increments('id');        table.uuid('uuid').index().unique().notNullable();        table.integer('oid').index();        table.specificType('geom', 'geometry').index(null, 'GIST');        table.text('slope');        table.datetime('deleted_at');        table.timestamps(true, true);    });",
  1216.         fields: ["uuid", "oid", "geom", "slope"],
  1217.         references: {},
  1218.         uniques: ["uuid"]
  1219.       },
  1220.       "FL"
  1221.     );
  1222.     if ((await knex.schema.hasTable("fl_ffs_priority")) == false) {
  1223.       await knex.schema.createTable("fl_ffs_priority", function(table) {
  1224.         table.increments("id");
  1225.         table
  1226.           .uuid("uuid")
  1227.           .index()
  1228.           .unique()
  1229.           .notNullable();
  1230.         table.integer("oid").index();
  1231.         table.specificType("geom", "geometry").index(null, "GIST");
  1232.         table.text("priority");
  1233.         table.datetime("deleted_at");
  1234.         table.timestamps(true, true);
  1235.       });
  1236.     }
  1237.     fieldMaps["Priority_2015_FFS_FL_Priority_2015_FFS_FL_shp"] = {
  1238.       uuid: "",
  1239.       oid: "Id",
  1240.       geom: "",
  1241.       priority: ""
  1242.     };
  1243.     relationMaps["Priority_2015_FFS_FL_Priority_2015_FFS_FL_shp"] = {};
  1244.     await runMigrationWith(
  1245.       "data/GIS/GIS_Processed_Data/WC_Florida/WC_FL_V0.1/Priority_2015_FFS_FL.zip",
  1246.       "fl_ffs_priority",
  1247.       {
  1248.         table: "fl_ffs_priority",
  1249.         func:
  1250.           "    await knex.schema.createTable('fl_ffs_priority', function (table) {        table.increments('id');        table.uuid('uuid').index().unique().notNullable();        table.integer('oid').index();        table.specificType('geom', 'geometry').index(null, 'GIST');        table.text('priority');        table.datetime('deleted_at');        table.timestamps(true, true);    });",
  1251.         fields: ["uuid", "oid", "geom", "priority"],
  1252.         references: {},
  1253.         uniques: ["uuid"]
  1254.       },
  1255.       "FL"
  1256.     );
  1257.     if ((await knex.schema.hasTable("fl_longleaf")) == false) {
  1258.       await knex.schema.createTable("fl_longleaf", function(table) {
  1259.         table.increments("id");
  1260.         table
  1261.           .uuid("uuid")
  1262.           .index()
  1263.           .unique()
  1264.           .notNullable();
  1265.         table.integer("oid").index();
  1266.         table.specificType("geom", "geometry").index(null, "GIST");
  1267.         table.text("priority");
  1268.         table.datetime("deleted_at");
  1269.         table.timestamps(true, true);
  1270.       });
  1271.     }
  1272.     fieldMaps["Longleaf_Prioirty_FL_llp_priorityareas_all_Simplified_shp"] = {
  1273.       uuid: "",
  1274.       oid: "",
  1275.       geom: "",
  1276.       priority: ""
  1277.     };
  1278.     relationMaps[
  1279.       "Longleaf_Prioirty_FL_llp_priorityareas_all_Simplified_shp"
  1280.     ] = {};
  1281.     fieldMaps["Longleaf_Prioirty_FL_llp_priorityareas_High_shp"] = {
  1282.       uuid: "",
  1283.       oid: "",
  1284.       geom: "",
  1285.       priority: ""
  1286.     };
  1287.     relationMaps["Longleaf_Prioirty_FL_llp_priorityareas_High_shp"] = {};
  1288.     await runMigrationWith(
  1289.       "data/GIS/GIS_Processed_Data/WC_Florida/WC_FL_V0.1/Longleaf_Prioirty_FL.zip",
  1290.       "fl_longleaf",
  1291.       {
  1292.         table: "fl_longleaf",
  1293.         func:
  1294.           "    await knex.schema.createTable('fl_longleaf', function (table) {        table.increments('id');        table.uuid('uuid').index().unique().notNullable();        table.integer('oid').index();        table.specificType('geom', 'geometry').index(null, 'GIST');        table.text('priority');        table.datetime('deleted_at');        table.timestamps(true, true);    });",
  1295.         fields: ["uuid", "oid", "geom", "priority"],
  1296.         references: {},
  1297.         uniques: ["uuid"]
  1298.       },
  1299.       "FL"
  1300.     );
  1301.     if ((await knex.schema.hasTable("fl_strategic_habitats")) == false) {
  1302.       await knex.schema.createTable("fl_strategic_habitats", function(table) {
  1303.         table.increments("id");
  1304.         table
  1305.           .uuid("uuid")
  1306.           .index()
  1307.           .unique()
  1308.           .notNullable();
  1309.         table.integer("oid").index();
  1310.         table.specificType("geom", "geometry").index(null, "GIST");
  1311.         table.text("habitat");
  1312.         table.datetime("deleted_at");
  1313.         table.timestamps(true, true);
  1314.       });
  1315.     }
  1316.     fieldMaps["Strategic_Habitat_FL_Strategic_Habitat_FL_shp"] = {
  1317.       uuid: "",
  1318.       oid: "OBJECTID",
  1319.       geom: "",
  1320.       habitat: ""
  1321.     };
  1322.     relationMaps["Strategic_Habitat_FL_Strategic_Habitat_FL_shp"] = {};
  1323.     await runMigrationWith(
  1324.       "data/GIS/GIS_Processed_Data/WC_Florida/WC_FL_V0.1/Strategic_Habitat_FL.zip",
  1325.       "fl_strategic_habitats",
  1326.       {
  1327.         table: "fl_strategic_habitats",
  1328.         func:
  1329.           "    await knex.schema.createTable('fl_strategic_habitats', function (table) {        table.increments('id');        table.uuid('uuid').index().unique().notNullable();        table.integer('oid').index();        table.specificType('geom', 'geometry').index(null, 'GIST');        table.text('habitat');        table.datetime('deleted_at');        table.timestamps(true, true);    });",
  1330.         fields: ["uuid", "oid", "geom", "habitat"],
  1331.         references: {},
  1332.         uniques: ["uuid"]
  1333.       },
  1334.       "FL"
  1335.     );
  1336.     if ((await knex.schema.hasTable("fl_mills")) == false) {
  1337.       await knex.schema.createTable("fl_mills", function(table) {
  1338.         table.increments("id");
  1339.         table
  1340.           .uuid("uuid")
  1341.           .index()
  1342.           .unique()
  1343.           .notNullable();
  1344.         table.integer("oid").index();
  1345.         table.specificType("geom", "geometry").index(null, "GIST");
  1346.         table.text("mill");
  1347.         table.datetime("deleted_at");
  1348.         table.timestamps(true, true);
  1349.       });
  1350.     }
  1351.     fieldMaps["Mills_FL_Mills_FL_shp"] = {
  1352.       uuid: "",
  1353.       oid: "",
  1354.       geom: "",
  1355.       mill: "NAME"
  1356.     };
  1357.     relationMaps["Mills_FL_Mills_FL_shp"] = {};
  1358.     await runMigrationWith(
  1359.       "data/GIS/GIS_Processed_Data/WC_Florida/WC_FL_V0.1/Mills_FL.zip",
  1360.       "fl_mills",
  1361.       {
  1362.         table: "fl_mills",
  1363.         func:
  1364.           "    await knex.schema.createTable('fl_mills', function (table) {        table.increments('id');        table.uuid('uuid').index().unique().notNullable();        table.integer('oid').index();        table.specificType('geom', 'geometry').index(null, 'GIST');        table.text('mill');        table.datetime('deleted_at');        table.timestamps(true, true);    });",
  1365.         fields: ["uuid", "oid", "geom", "mill"],
  1366.         references: {},
  1367.         uniques: ["uuid"]
  1368.       },
  1369.       "FL"
  1370.     );
  1371.     if ((await knex.schema.hasTable("fl_invasive")) == false) {
  1372.       await knex.schema.createTable("fl_invasive", function(table) {
  1373.         table.increments("id");
  1374.         table
  1375.           .uuid("uuid")
  1376.           .index()
  1377.           .unique()
  1378.           .notNullable();
  1379.         table.integer("oid").index();
  1380.         table.specificType("geom", "geometry").index(null, "GIST");
  1381.         table.text("species");
  1382.         table.datetime("deleted_at");
  1383.         table.timestamps(true, true);
  1384.       });
  1385.     }
  1386.     fieldMaps["Invasive_FL_Invasive_FL_shp"] = {
  1387.       uuid: "",
  1388.       oid: "OBJECTID",
  1389.       geom: "",
  1390.       species: "SCINAME"
  1391.     };
  1392.     relationMaps["Invasive_FL_Invasive_FL_shp"] = {};
  1393.     fieldMaps["Invasive_FL_Invasive_1mile_FL_shp"] = {
  1394.       uuid: "",
  1395.       oid: "OBJECTID",
  1396.       geom: "",
  1397.       species: "SCINAME"
  1398.     };
  1399.     relationMaps["Invasive_FL_Invasive_1mile_FL_shp"] = {};
  1400.     await runMigrationWith(
  1401.       "data/GIS/GIS_Processed_Data/WC_Florida/WC_FL_V0.1/Invasive_FL.zip",
  1402.       "fl_invasive",
  1403.       {
  1404.         table: "fl_invasive",
  1405.         func:
  1406.           "    await knex.schema.createTable('fl_invasive', function (table) {        table.increments('id');        table.uuid('uuid').index().unique().notNullable();        table.integer('oid').index();        table.specificType('geom', 'geometry').index(null, 'GIST');        table.text('species');        table.datetime('deleted_at');        table.timestamps(true, true);    });",
  1407.         fields: ["uuid", "oid", "geom", "species"],
  1408.         references: {},
  1409.         uniques: ["uuid"]
  1410.       },
  1411.       "FL"
  1412.     );
  1413.   })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement