text: -- Backfill of USCRN to 2001
  
  do
  $do$
  declare
       year int;
       mytable varchar;
  begin
      for year in 2001..2005
      loop
          mytable := format($f$uscrn_t%s$f$, year);
          execute format($f$
              create table %s partition of uscrn_alldata
              for values from ('%s-01-01 00:00+00') to ('%s-01-01 00:00+00')
              $f$, mytable, year, year + 1);
          execute format($f$
              ALTER TABLE %s OWNER to mesonet
          $f$, mytable);
          execute format($f$
              GRANT ALL on %s to ldm
          $f$, mytable);
          execute format($f$
              GRANT SELECT on %s to nobody,apache
          $f$, mytable);
          -- Indices
          execute format($f$
              CREATE INDEX %s_station_idx on %s(station)
          $f$, mytable, mytable);
          execute format($f$
              CREATE INDEX %s_valid_idx on %s(valid)
          $f$, mytable, mytable);
      end loop;
  end;
  $do$;
  