/[openfoncier]/trunk/data/pgsql/init_metier.sql
ViewVC logotype

Diff of /trunk/data/pgsql/init_metier.sql

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2055 by vpihour, Fri Jun 28 18:14:01 2013 UTC revision 2056 by vpihour, Mon Jul 1 13:19:53 2013 UTC
# Line 15  Line 15 
15  -- PostgreSQL database dump  -- PostgreSQL database dump
16  --  --
17    
 CREATE SCHEMA openads;  
   
   
 SET search_path = openads, pg_catalog;  
   
 --  
 -- Name: fn_fixsequences(); Type: FUNCTION; Schema: openads; Owner: -  
 --  
   
 CREATE FUNCTION fn_fixsequences() RETURNS integer  
     LANGUAGE plpgsql  
     AS $$  
 DECLARE  
 themax BIGINT;  
 mytables RECORD;  
 num integer;  
 BEGIN  
  num := 0;  
  FOR mytables IN  
     SELECT  S.relname as seq, C.attname as attname, T.relname as relname  
     FROM pg_class AS S, pg_depend AS D, pg_class AS T, pg_attribute AS C  
     WHERE S.relkind = 'S'  
         AND S.oid = D.objid  
         AND D.refobjid = T.oid  
         AND D.refobjid = C.attrelid  
         AND D.refobjsubid = C.attnum  
  LOOP  
       EXECUTE 'SELECT MAX('||mytables.attname||') FROM '||mytables.relname||';' INTO themax;  
       IF (themax is null OR themax < 0) THEN  
        themax := 0;  
       END IF;  
       themax := themax +1;  
       EXECUTE 'ALTER SEQUENCE ' || mytables.seq || ' RESTART WITH '||themax;  
       num := num + 1;  
   END LOOP;  
     
   RETURN num;  
     
 END;  
 $$;  
   
   
 SET default_tablespace = '';  
   
 SET default_with_oids = false;  
   
18  --  --
19  -- Name: action; Type: TABLE; Schema: openads; Owner: -; Tablespace:  -- Name: action; Type: TABLE; Schema: openads; Owner: -; Tablespace:
20  --  --
# Line 1621  CREATE TABLE dossier ( Line 1575  CREATE TABLE dossier (
1575      etat_pendant_incompletude character varying(20),      etat_pendant_incompletude character varying(20),
1576      date_limite_incompletude date,      date_limite_incompletude date,
1577      delai_incompletude integer,      delai_incompletude integer,
1578      geom public.geometry(Point,2154),      geom text,
1579      geom1 public.geometry(MultiPolygon,2154)      geom1 text
1580  );  );
1581    
1582    
# Line 2549  CREATE TABLE parcelle ( Line 2503  CREATE TABLE parcelle (
2503      surface double precision,      surface double precision,
2504      section character varying(7),      section character varying(7),
2505      commune character varying(5),      commune character varying(5),
2506      geom public.geometry(Polygon,2154)      geom text
2507  );  );
2508    
2509    
# Line 2564  CREATE TABLE parcelle_lot ( Line 2518  CREATE TABLE parcelle_lot (
2518      lotissement character varying(50) NOT NULL,      lotissement character varying(50) NOT NULL,
2519      numero character varying(16),      numero character varying(16),
2520      surface numeric(10,3),      surface numeric(10,3),
2521      geom public.geometry(Polygon,2154)      geom text
2522  );  );
2523    
2524    
# Line 2594  ALTER SEQUENCE parcelle_lot_seq OWNED BY Line 2548  ALTER SEQUENCE parcelle_lot_seq OWNED BY
2548  CREATE TABLE pos (  CREATE TABLE pos (
2549      pos character varying(10) NOT NULL,      pos character varying(10) NOT NULL,
2550      libelle character varying(40) NOT NULL,      libelle character varying(40) NOT NULL,
2551      geom public.geometry(Polygon,2154)      geom text
2552  );  );
2553    
2554    
# Line 2805  CREATE TABLE servitude_ligne ( Line 2759  CREATE TABLE servitude_ligne (
2759      observation character varying(80),      observation character varying(80),
2760      perimetre integer,      perimetre integer,
2761      description text,      description text,
2762      geom public.geometry(LineString,2154)      geom text
2763  );  );
2764    
2765    
# Line 2838  CREATE TABLE servitude_point ( Line 2792  CREATE TABLE servitude_point (
2792      observation character varying(80),      observation character varying(80),
2793      perimetre integer,      perimetre integer,
2794      description text,      description text,
2795      geom public.geometry(Point,2154)      geom text
2796  );  );
2797    
2798    
# Line 2871  CREATE TABLE servitude_surfacique ( Line 2825  CREATE TABLE servitude_surfacique (
2825      observation character varying(80),      observation character varying(80),
2826      perimetre integer,      perimetre integer,
2827      description text,      description text,
2828      geom public.geometry(Polygon,2154)      geom text
2829  );  );
2830    
2831    

Legend:
Removed from v.2055  
changed lines
  Added in v.2056

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26