 -- ABS census 2021 - meshblocks
 --------------------------------------------------------------------------------------
 
-DROP TABLE IF EXISTS admin_bdys_202108.abs_2021_mb CASCADE;
-CREATE TABLE admin_bdys_202108.abs_2021_mb AS
+DROP TABLE IF EXISTS admin_bdys.abs_2021_mb CASCADE;
+CREATE TABLE admin_bdys.abs_2021_mb AS
 SELECT tab.gid,
        mb_21ppid,
        tab.dt_create,

       area_sqm,
       loci21_uri::text,
       geom
  FROM raw_admin_bdys_202108.aus_sa3_2021 AS tab
  INNER JOIN raw_admin_bdys_202108.aus_state AS ste ON tab.state_pid = ste.state_pid;

ALTER TABLE admin_bdys_202108.abs_2021_sa3 ADD CONSTRAINT abs_2021_sa3_pk PRIMARY KEY (gid);
CREATE INDEX abs_2021_sa3_geom_idx ON admin_bdys_202108.abs_2021_sa3 USING gist(geom);
ALTER TABLE admin_bdys_202108.abs_2021_sa3 CLUSTER ON abs_2021_sa3_geom_idx;


-- # ---------------------------------------------------------------------------------
-- ABS census 2021 - statistical area 4's
--------------------------------------------------------------------------------------

DROP TABLE IF EXISTS admin_bdys_202108.abs_2021_sa4 CASCADE;
CREATE TABLE admin_bdys_202108.abs_2021_sa4 AS
SELECT tab.gid,
       sa4_21ppid,
       tab.dt_create,

       area_sqm,
       loci21_uri::text,
       geom
  FROM raw_admin_bdys.aus_sa2_2021 AS tab
  INNER JOIN raw_admin_bdys.aus_state AS ste ON tab.state_pid = ste.state_pid;

ALTER TABLE admin_bdys.abs_2021_sa2 ADD CONSTRAINT abs_2021_sa2_pk PRIMARY KEY (gid);
CREATE INDEX abs_2021_sa2_geom_idx ON admin_bdys.abs_2021_sa2 USING gist(geom);
ALTER TABLE admin_bdys.abs_2021_sa2 CLUSTER ON abs_2021_sa2_geom_idx;


-- # ---------------------------------------------------------------------------------
-- ABS census 2021 - statistical area 3's
--------------------------------------------------------------------------------------

DROP TABLE IF EXISTS admin_bdys.abs_2021_sa3 CASCADE;
CREATE TABLE admin_bdys.abs_2021_sa3 AS
SELECT tab.gid,
       sa3_21ppid,
       tab.dt_create,
