Skip to content
Snippets Groups Projects
schema-191.sql 110 KiB
Newer Older
  • Learn to ignore specific revisions
  •     timestamp_array_value time_stamp[],
        json_value jsonb,
        CONSTRAINT maprh_ck CHECK ((
                ((value IS NOT NULL) AND (vocabulary_term IS NULL) AND (material IS NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NULL))
                    OR ((value IS NULL) AND (vocabulary_term IS NOT NULL) AND (material IS NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NULL))
                    OR ((value IS NULL) AND (vocabulary_term IS NULL) AND (material IS NOT NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NULL))
                    OR ((value IS NULL) AND (vocabulary_term IS NULL) AND (material IS NULL) AND (integer_array_value IS NOT NULL) AND (real_array_value IS NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NULL))
                    OR ((value IS NULL) AND (vocabulary_term IS NULL) AND (material IS NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NOT NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NULL))
                    OR ((value IS NULL) AND (vocabulary_term IS NULL) AND (material IS NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NULL) AND (string_array_value IS NOT NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NULL))
                    OR ((value IS NULL) AND (vocabulary_term IS NULL) AND (material IS NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NOT NULL) AND (json_value IS NULL))
                    OR ((value IS NULL) AND (vocabulary_term IS NULL) AND (material IS NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NOT NULL))
            ))
    
    2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711
    );
    CREATE SEQUENCE material_property_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE SEQUENCE material_type_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE TABLE material_type_property_types (
        id tech_id NOT NULL,
        maty_id tech_id NOT NULL,
        prty_id tech_id NOT NULL,
        is_mandatory boolean_char DEFAULT false NOT NULL,
        is_managed_internally boolean_char DEFAULT false NOT NULL,
        registration_timestamp time_stamp_dfl DEFAULT now() NOT NULL,
        pers_id_registerer tech_id NOT NULL,
        section description_2000,
        ordinal ordinal_int NOT NULL,
        script_id tech_id,
        is_shown_edit boolean_char DEFAULT true NOT NULL,
        show_raw_value boolean_char DEFAULT false NOT NULL,
        is_unique boolean_char DEFAULT false NOT NULL
    );
    CREATE TABLE material_types (
        id tech_id NOT NULL,
        code code NOT NULL,
        description description_2000,
        modification_timestamp time_stamp DEFAULT now(),
        validation_script_id tech_id
    );
    CREATE TABLE materials (
        id tech_id NOT NULL,
        code code NOT NULL,
        maty_id tech_id NOT NULL,
        pers_id_registerer tech_id NOT NULL,
        registration_timestamp time_stamp_dfl DEFAULT now() NOT NULL,
        modification_timestamp time_stamp DEFAULT now(),
        tsvector_document tsvector NOT NULL
    );
    CREATE SEQUENCE metaproject_assignment_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE TABLE metaproject_assignments_all (
        id tech_id NOT NULL,
        mepr_id tech_id NOT NULL,
        expe_id tech_id,
        samp_id tech_id,
        data_id tech_id,
        mate_id tech_id,
        del_id tech_id,
        creation_date time_stamp_dfl DEFAULT now() NOT NULL,
        CONSTRAINT metaproject_assignments_all_check_nn CHECK ((((expe_id IS NOT NULL) AND (samp_id IS NULL) AND (data_id IS NULL) AND (mate_id IS NULL)) OR ((expe_id IS NULL) AND (samp_id IS NOT NULL) AND (data_id IS NULL) AND (mate_id IS NULL)) OR ((expe_id IS NULL) AND (samp_id IS NULL) AND (data_id IS NOT NULL) AND (mate_id IS NULL)) OR ((expe_id IS NULL) AND (samp_id IS NULL) AND (data_id IS NULL) AND (mate_id IS NOT NULL))))
    );
    CREATE VIEW metaproject_assignments AS
     SELECT metaproject_assignments_all.id,
        metaproject_assignments_all.mepr_id,
        metaproject_assignments_all.expe_id,
        metaproject_assignments_all.samp_id,
        metaproject_assignments_all.data_id,
        metaproject_assignments_all.mate_id,
        metaproject_assignments_all.del_id,
        metaproject_assignments_all.creation_date
       FROM metaproject_assignments_all
      WHERE (metaproject_assignments_all.del_id IS NULL);
    CREATE SEQUENCE metaproject_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE TABLE metaprojects (
        id tech_id NOT NULL,
        name code NOT NULL,
        description description_2000,
        owner tech_id NOT NULL,
        private boolean_char DEFAULT true NOT NULL,
        creation_date time_stamp_dfl DEFAULT now() NOT NULL
    );
    CREATE SEQUENCE mtpt_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE TABLE operation_executions (
        id tech_id NOT NULL,
        code code NOT NULL,
        state operation_execution_state DEFAULT 'NEW'::character varying NOT NULL,
        owner tech_id NOT NULL,
        description text_value,
        notification text_value,
        availability operation_execution_availability DEFAULT 'AVAILABLE'::character varying NOT NULL,
        availability_time bigint DEFAULT 1 NOT NULL,
        summary_operations text_value,
        summary_progress text_value,
        summary_error text_value,
        summary_results text_value,
        summary_availability operation_execution_availability DEFAULT 'AVAILABLE'::character varying NOT NULL,
        summary_availability_time bigint DEFAULT 1 NOT NULL,
        details_path character varying(1000),
        details_availability operation_execution_availability DEFAULT 'AVAILABLE'::character varying NOT NULL,
        details_availability_time bigint DEFAULT 1 NOT NULL,
        creation_date time_stamp_dfl NOT NULL,
        start_date time_stamp,
        finish_date time_stamp,
        CONSTRAINT operation_executions_state_finish_date_check CHECK (((((state)::text = ANY (ARRAY[('NEW'::character varying)::text, ('SCHEDULED'::character varying)::text, ('RUNNING'::character varying)::text])) AND (finish_date IS NULL)) OR (((state)::text = ANY (ARRAY[('FINISHED'::character varying)::text, ('FAILED'::character varying)::text])) AND (finish_date IS NOT NULL)))),
        CONSTRAINT operation_executions_state_start_date_check CHECK (((((state)::text = ANY (ARRAY[('NEW'::character varying)::text, ('SCHEDULED'::character varying)::text])) AND (start_date IS NULL)) OR (((state)::text = ANY (ARRAY[('RUNNING'::character varying)::text, ('FINISHED'::character varying)::text, ('FAILED'::character varying)::text])) AND (start_date IS NOT NULL))))
    );
    CREATE SEQUENCE operation_executions_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE SEQUENCE perm_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE SEQUENCE person_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE TABLE persons (
        id tech_id NOT NULL,
        first_name character varying(30),
        last_name character varying(30),
        user_id user_id NOT NULL,
        email object_name,
        space_id tech_id,
        registration_timestamp time_stamp_dfl DEFAULT now() NOT NULL,
        pers_id_registerer tech_id,
        display_settings file,
        is_active boolean DEFAULT true
    );
    CREATE TABLE post_registration_dataset_queue (
        id tech_id NOT NULL,
        ds_id tech_id NOT NULL
    );
    CREATE SEQUENCE post_registration_dataset_queue_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE SEQUENCE project_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE TABLE project_relationships_history (
        id tech_id NOT NULL,
        main_proj_id tech_id NOT NULL,
        relation_type text_value,
        expe_id tech_id,
        space_id tech_id,
        entity_perm_id text_value,
        pers_id_author tech_id,
        valid_from_timestamp time_stamp NOT NULL,
        valid_until_timestamp time_stamp,
        entity_kind text_value,
        samp_id tech_id
    );
    CREATE SEQUENCE project_relationships_history_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE TABLE projects (
        id tech_id NOT NULL,
        perm_id code NOT NULL,
        code code NOT NULL,
        space_id tech_id NOT NULL,
        pers_id_leader tech_id,
        description text_value,
        pers_id_registerer tech_id NOT NULL,
        registration_timestamp time_stamp_dfl DEFAULT now() NOT NULL,
        modification_timestamp time_stamp DEFAULT now(),
        pers_id_modifier tech_id,
        version integer DEFAULT 0,
        frozen boolean_char DEFAULT false NOT NULL,
        frozen_for_exp boolean_char DEFAULT false NOT NULL,
        frozen_for_samp boolean_char DEFAULT false NOT NULL,
        space_frozen boolean_char DEFAULT false NOT NULL
    );
    CREATE SEQUENCE property_type_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE TABLE property_types (
        id tech_id NOT NULL,
        code code NOT NULL,
        description description_2000 NOT NULL,
        label column_label NOT NULL,
        daty_id tech_id NOT NULL,
        registration_timestamp time_stamp_dfl DEFAULT now() NOT NULL,
        pers_id_registerer tech_id NOT NULL,
        covo_id tech_id,
        is_managed_internally boolean_char DEFAULT false NOT NULL,
        maty_prop_id tech_id,
        schema text_value,
        transformation text_value,
        meta_data jsonb,
        saty_prop_id tech_id
    );
    CREATE TABLE queries (
        id tech_id NOT NULL,
        name character varying(200) NOT NULL,
        description description_2000,
        registration_timestamp time_stamp_dfl DEFAULT now() NOT NULL,
        pers_id_registerer tech_id NOT NULL,
        modification_timestamp time_stamp DEFAULT now(),
        expression text NOT NULL,
        is_public boolean NOT NULL,
        query_type query_type NOT NULL,
        db_key code DEFAULT '1'::character varying NOT NULL,
        entity_type_code code
    );
    CREATE SEQUENCE query_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE SEQUENCE relationship_type_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE TABLE relationship_types (
        id tech_id NOT NULL,
        code code NOT NULL,
        label column_label,
        parent_label column_label,
        child_label column_label,
        description description_2000,
        registration_timestamp time_stamp_dfl DEFAULT now() NOT NULL,
        pers_id_registerer tech_id NOT NULL,
        is_managed_internally boolean_char DEFAULT false NOT NULL
    );
    CREATE SEQUENCE role_assignment_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE TABLE role_assignments (
        id tech_id NOT NULL,
        role_code authorization_role NOT NULL,
        space_id tech_id,
        pers_id_grantee tech_id,
        pers_id_registerer tech_id NOT NULL,
        registration_timestamp time_stamp_dfl DEFAULT now() NOT NULL,
        ag_id_grantee tech_id,
        project_id tech_id,
        CONSTRAINT roas_ag_pers_arc_ck CHECK ((((ag_id_grantee IS NOT NULL) AND (pers_id_grantee IS NULL)) OR ((ag_id_grantee IS NULL) AND (pers_id_grantee IS NOT NULL)))),
        CONSTRAINT roas_space_project_ck CHECK (((space_id IS NULL) OR (project_id IS NULL)))
    );
    CREATE SEQUENCE sample_code_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE TABLE sample_properties_history (
        id tech_id NOT NULL,
        samp_id tech_id NOT NULL,
        stpt_id tech_id NOT NULL,
        value text_value,
        valid_until_timestamp time_stamp DEFAULT now(),
        pers_id_author tech_id NOT NULL,
        valid_from_timestamp time_stamp NOT NULL,
        vocabulary_term identifier,
        material identifier,
        sample identifier,
        integer_array_value long_value[],
        real_array_value double_value[],
        string_array_value text_value[],
        timestamp_array_value time_stamp[],
        json_value jsonb,
        CONSTRAINT saprh_ck CHECK ((
            ((value IS NOT NULL) AND (vocabulary_term IS NULL) AND (material IS NULL) AND (sample IS NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NULL))
                OR ((value IS NULL) AND (vocabulary_term IS NOT NULL) AND (material IS NULL) AND (sample IS NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NULL))
                OR ((value IS NULL) AND (vocabulary_term IS NULL) AND (material IS NOT NULL) AND (sample IS NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NULL))
                OR ((value IS NULL) AND (vocabulary_term IS NULL) AND (material IS NULL) AND (sample IS NOT NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NULL))
                OR ((value IS NULL) AND (vocabulary_term IS NULL) AND (material IS NULL) AND (sample IS NULL) AND (integer_array_value IS NOT NULL) AND (real_array_value IS NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NULL))
                OR ((value IS NULL) AND (vocabulary_term IS NULL) AND (material IS NULL) AND (sample IS NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NOT NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NULL))
                OR ((value IS NULL) AND (vocabulary_term IS NULL) AND (material IS NULL) AND (sample IS NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NULL) AND (string_array_value IS NOT NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NULL))
                OR ((value IS NULL) AND (vocabulary_term IS NULL) AND (material IS NULL) AND (sample IS NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NOT NULL) AND (json_value IS NULL))
                OR ((value IS NULL) AND (vocabulary_term IS NULL) AND (material IS NULL) AND (sample IS NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NOT NULL))
            ))
    );
    CREATE TABLE sample_relationships_history (
        id tech_id NOT NULL,
        main_samp_id tech_id NOT NULL,
        relation_type text_value,
        expe_id tech_id,
        samp_id tech_id,
        data_id tech_id,
        entity_perm_id text_value,
        pers_id_author tech_id,
        valid_from_timestamp time_stamp NOT NULL,
        valid_until_timestamp time_stamp,
        space_id tech_id,
        proj_id tech_id,
        annotations jsonb,
        entity_kind text_value
    );
    CREATE VIEW sample_history_view AS
     SELECT (2 * (sample_relationships_history.id)::bigint) AS id,
        sample_relationships_history.main_samp_id,
        sample_relationships_history.relation_type,
        sample_relationships_history.space_id,
        sample_relationships_history.expe_id,
        sample_relationships_history.samp_id,
        sample_relationships_history.proj_id,
        sample_relationships_history.data_id,
        sample_relationships_history.entity_kind,
        sample_relationships_history.entity_perm_id,
        sample_relationships_history.annotations,
        NULL::bigint AS stpt_id,
        NULL::text AS value,
        NULL::character varying AS vocabulary_term,
        NULL::character varying AS material,
        NULL::character varying AS sample,
        sample_relationships_history.pers_id_author,
        sample_relationships_history.valid_from_timestamp,
        sample_relationships_history.valid_until_timestamp,
        NULL::long_value[] AS integer_array_value,
        NULL::double_value[] AS real_array_value,
        NULL::text_value[] AS string_array_value,
        NULL::time_stamp[] AS timestamp_array_value,
        NULL::jsonb AS json_value
       FROM sample_relationships_history
      WHERE (sample_relationships_history.valid_until_timestamp IS NOT NULL)
    UNION
     SELECT ((2 * (sample_properties_history.id)::bigint) + 1) AS id,
        sample_properties_history.samp_id AS main_samp_id,
        NULL::text AS relation_type,
        NULL::bigint AS space_id,
        NULL::bigint AS expe_id,
        NULL::bigint AS samp_id,
        NULL::bigint AS proj_id,
        NULL::bigint AS data_id,
        NULL::text AS entity_kind,
        NULL::text AS entity_perm_id,
        NULL::jsonb AS annotations,
        sample_properties_history.stpt_id,
        sample_properties_history.value,
        sample_properties_history.vocabulary_term,
        sample_properties_history.material,
        sample_properties_history.sample,
        sample_properties_history.pers_id_author,
        sample_properties_history.valid_from_timestamp,
        sample_properties_history.valid_until_timestamp,
        sample_properties_history.integer_array_value,
        sample_properties_history.real_array_value,
        sample_properties_history.string_array_value,
        sample_properties_history.timestamp_array_value,
        sample_properties_history.json_value
       FROM sample_properties_history;
    CREATE SEQUENCE sample_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE TABLE sample_properties (
        id tech_id NOT NULL,
        samp_id tech_id NOT NULL,
        stpt_id tech_id NOT NULL,
        value text_value,
        cvte_id tech_id,
        pers_id_registerer tech_id NOT NULL,
        registration_timestamp time_stamp_dfl DEFAULT now() NOT NULL,
        modification_timestamp time_stamp DEFAULT now(),
        mate_prop_id tech_id,
        pers_id_author tech_id NOT NULL,
        samp_frozen boolean_char DEFAULT false NOT NULL,
        samp_prop_id tech_id,
        tsvector_document tsvector NOT NULL,
        is_unique boolean_char DEFAULT false NOT NULL,
        integer_array_value long_value[],
        real_array_value double_value[],
        string_array_value text_value[],
        timestamp_array_value time_stamp[],
        json_value jsonb,
        CONSTRAINT sapr_ck CHECK ((
            ((value IS NOT NULL) AND (cvte_id IS NULL) AND (mate_prop_id IS NULL) AND (samp_prop_id IS NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NULL))
                OR ((value IS NULL) AND (cvte_id IS NOT NULL) AND (mate_prop_id IS NULL) AND (samp_prop_id IS NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NULL))
                OR ((value IS NULL) AND (cvte_id IS NULL) AND (mate_prop_id IS NOT NULL) AND (samp_prop_id IS NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NULL))
                OR ((value IS NULL) AND (cvte_id IS NULL) AND (mate_prop_id IS NULL) AND (samp_prop_id IS NOT NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NULL))
                OR ((value IS NULL) AND (cvte_id IS NULL) AND (mate_prop_id IS NULL) AND (samp_prop_id IS NULL) AND (integer_array_value IS NOT NULL) AND (real_array_value IS NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NULL))
                OR ((value IS NULL) AND (cvte_id IS NULL) AND (mate_prop_id IS NULL) AND (samp_prop_id IS NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NOT NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NULL))
                OR ((value IS NULL) AND (cvte_id IS NULL) AND (mate_prop_id IS NULL) AND (samp_prop_id IS NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NULL) AND (string_array_value IS NOT NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NULL))
                OR ((value IS NULL) AND (cvte_id IS NULL) AND (mate_prop_id IS NULL) AND (samp_prop_id IS NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NOT NULL) AND (json_value IS NULL))
                OR ((value IS NULL) AND (cvte_id IS NULL) AND (mate_prop_id IS NULL) AND (samp_prop_id IS NULL) AND (integer_array_value IS NULL) AND (real_array_value IS NULL) AND (string_array_value IS NULL) AND (timestamp_array_value IS NULL) AND (json_value IS NOT NULL))
            ))
    );
    CREATE SEQUENCE sample_property_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE SEQUENCE sample_relationship_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE TABLE sample_relationships_all (
        id tech_id NOT NULL,
        sample_id_parent tech_id NOT NULL,
        relationship_id tech_id NOT NULL,
        sample_id_child tech_id NOT NULL,
        del_id tech_id,
        pers_id_author tech_id,
        registration_timestamp time_stamp_dfl DEFAULT now() NOT NULL,
        modification_timestamp time_stamp DEFAULT now(),
        parent_frozen boolean_char DEFAULT false NOT NULL,
        child_frozen boolean_char DEFAULT false NOT NULL,
        child_annotations jsonb,
        parent_annotations jsonb
    );
    CREATE VIEW sample_relationships AS
     SELECT sample_relationships_all.id,
        sample_relationships_all.sample_id_parent,
        sample_relationships_all.parent_frozen,
        sample_relationships_all.relationship_id,
        sample_relationships_all.sample_id_child,
        sample_relationships_all.child_frozen,
        sample_relationships_all.del_id,
        sample_relationships_all.pers_id_author,
        sample_relationships_all.registration_timestamp,
        sample_relationships_all.modification_timestamp,
        sample_relationships_all.child_annotations,
        sample_relationships_all.parent_annotations
       FROM sample_relationships_all
      WHERE (sample_relationships_all.del_id IS NULL);
    CREATE SEQUENCE sample_relationships_history_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE SEQUENCE sample_type_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE TABLE sample_type_property_types (
        id tech_id NOT NULL,
        saty_id tech_id NOT NULL,
        prty_id tech_id NOT NULL,
        is_mandatory boolean_char DEFAULT false NOT NULL,
        is_managed_internally boolean_char DEFAULT false NOT NULL,
        pers_id_registerer tech_id NOT NULL,
        registration_timestamp time_stamp_dfl DEFAULT now() NOT NULL,
        is_displayed boolean_char DEFAULT true NOT NULL,
        section description_2000,
        ordinal ordinal_int NOT NULL,
        script_id tech_id,
        is_shown_edit boolean_char DEFAULT true NOT NULL,
        show_raw_value boolean_char DEFAULT false NOT NULL,
        is_unique boolean_char DEFAULT false NOT NULL
    );
    CREATE TABLE sample_types (
        id tech_id NOT NULL,
        code code NOT NULL,
        description description_2000,
        is_listable boolean_char DEFAULT true NOT NULL,
        generated_from_depth integer DEFAULT 0 NOT NULL,
        part_of_depth integer DEFAULT 0 NOT NULL,
        modification_timestamp time_stamp DEFAULT now(),
        is_auto_generated_code boolean_char DEFAULT false NOT NULL,
        generated_code_prefix code DEFAULT 'S'::character varying NOT NULL,
        is_subcode_unique boolean_char DEFAULT false NOT NULL,
        inherit_properties boolean_char DEFAULT false NOT NULL,
        validation_script_id tech_id,
        show_parent_metadata boolean_char DEFAULT false NOT NULL
    );
    CREATE TABLE samples_all (
        id tech_id NOT NULL,
        code code NOT NULL,
        saty_id tech_id NOT NULL,
        registration_timestamp time_stamp_dfl DEFAULT now() NOT NULL,
        pers_id_registerer tech_id NOT NULL,
        del_id tech_id,
        space_id tech_id,
        samp_id_part_of tech_id,
        modification_timestamp time_stamp DEFAULT now(),
        expe_id tech_id,
        perm_id code NOT NULL,
        pers_id_modifier tech_id,
        code_unique_check character varying(300),
        subcode_unique_check character varying(300),
        version integer DEFAULT 0,
        orig_del tech_id,
        proj_id tech_id,
        frozen boolean_char DEFAULT false NOT NULL,
        space_frozen boolean_char DEFAULT false NOT NULL,
        proj_frozen boolean_char DEFAULT false NOT NULL,
        expe_frozen boolean_char DEFAULT false NOT NULL,
        cont_frozen boolean_char DEFAULT false NOT NULL,
        frozen_for_comp boolean_char DEFAULT false NOT NULL,
        frozen_for_children boolean_char DEFAULT false NOT NULL,
        frozen_for_parents boolean_char DEFAULT false NOT NULL,
        frozen_for_data boolean_char DEFAULT false NOT NULL,
        sample_identifier sample_identifier,
        tsvector_document tsvector NOT NULL
    );
    CREATE VIEW samples AS
     SELECT samples_all.id,
        samples_all.perm_id,
        samples_all.code,
        samples_all.proj_id,
        samples_all.proj_frozen,
        samples_all.expe_id,
        samples_all.expe_frozen,
        samples_all.saty_id,
        samples_all.registration_timestamp,
        samples_all.modification_timestamp,
        samples_all.pers_id_registerer,
        samples_all.pers_id_modifier,
        samples_all.del_id,
        samples_all.orig_del,
        samples_all.space_id,
        samples_all.space_frozen,
        samples_all.samp_id_part_of,
        samples_all.cont_frozen,
        samples_all.version,
        samples_all.frozen,
        samples_all.frozen_for_comp,
        samples_all.frozen_for_children,
        samples_all.frozen_for_parents,
        samples_all.frozen_for_data,
        samples_all.tsvector_document,
        samples_all.sample_identifier
       FROM samples_all
      WHERE (samples_all.del_id IS NULL);
    CREATE VIEW samples_deleted AS
     SELECT samples_all.id,
        samples_all.perm_id,
        samples_all.code,
        samples_all.expe_id,
        samples_all.saty_id,
        samples_all.registration_timestamp,
        samples_all.modification_timestamp,
        samples_all.pers_id_registerer,
        samples_all.pers_id_modifier,
        samples_all.del_id,
        samples_all.orig_del,
        samples_all.space_id,
        samples_all.proj_id,
        samples_all.samp_id_part_of,
        samples_all.version
       FROM samples_all
      WHERE (samples_all.del_id IS NOT NULL);
    CREATE SEQUENCE script_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE TABLE scripts (
        id tech_id NOT NULL,
        name character varying(200) NOT NULL,
        description description_2000,
        script text_value,
        registration_timestamp time_stamp_dfl DEFAULT now() NOT NULL,
        pers_id_registerer tech_id NOT NULL,
        entity_kind entity_kind,
        script_type script_type NOT NULL,
        plugin_type plugin_type DEFAULT 'JYTHON'::character varying NOT NULL,
        is_available boolean_char DEFAULT true NOT NULL,
        CONSTRAINT script_nn_ck CHECK ((((plugin_type)::text = 'PREDEPLOYED'::text) OR (script IS NOT NULL)))
    );
    CREATE SEQUENCE semantic_annotation_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE TABLE semantic_annotations (
        id tech_id NOT NULL,
        perm_id code NOT NULL,
        saty_id tech_id,
        stpt_id tech_id,
        prty_id tech_id,
        predicate_ontology_id text,
        predicate_ontology_version text,
        predicate_accession_id text,
        descriptor_ontology_id text,
        descriptor_ontology_version text,
        descriptor_accession_id text,
        creation_date time_stamp_dfl NOT NULL,
        CONSTRAINT semantic_annotations_ssp_ck CHECK ((((saty_id IS NOT NULL) AND (stpt_id IS NULL) AND (prty_id IS NULL)) OR ((saty_id IS NULL) AND (stpt_id IS NOT NULL) AND (prty_id IS NULL)) OR ((saty_id IS NULL) AND (stpt_id IS NULL) AND (prty_id IS NOT NULL))))
    );
    CREATE SEQUENCE space_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    CREATE TABLE spaces (
        id tech_id NOT NULL,
        code code NOT NULL,
        description description_2000,
        registration_timestamp time_stamp_dfl DEFAULT now() NOT NULL,
        pers_id_registerer tech_id NOT NULL,
        frozen boolean_char DEFAULT false NOT NULL,
        frozen_for_proj boolean_char DEFAULT false NOT NULL,
        frozen_for_samp boolean_char DEFAULT false NOT NULL
    );
    CREATE SEQUENCE stpt_id_seq
        START WITH 1
        INCREMENT BY 1
        NO MINVALUE
        NO MAXVALUE
        CACHE 1;
    SELECT pg_catalog.setval('attachment_content_id_seq', 12, true);
    SELECT pg_catalog.setval('attachment_id_seq', 12, true);
    SELECT pg_catalog.setval('authorization_group_id_seq', 1, true);
    SELECT pg_catalog.setval('code_seq', 8, true);
    SELECT pg_catalog.setval('content_copies_id_seq', 4, true);
    SELECT pg_catalog.setval('controlled_vocabulary_id_seq', 6, true);
    SELECT pg_catalog.setval('core_plugin_id_seq', 1, false);
    SELECT pg_catalog.setval('cvte_id_seq', 17, true);
    SELECT pg_catalog.setval('data_id_seq', 41, true);
    SELECT pg_catalog.setval('data_set_copies_history_id_seq', 1, false);
    SELECT pg_catalog.setval('data_set_property_id_seq', 29, true);
    SELECT pg_catalog.setval('data_set_relationship_id_seq', 1, false);
    SELECT pg_catalog.setval('data_set_relationships_history_id_seq', 16, true);
    SELECT pg_catalog.setval('data_set_type_id_seq', 11, true);
    SELECT pg_catalog.setval('data_store_id_seq', 1, true);
    SELECT pg_catalog.setval('data_store_services_id_seq', 1, true);
    SELECT pg_catalog.setval('data_type_id_seq', 12, true);
    SELECT pg_catalog.setval('database_instance_id_seq', 1, true);
    SELECT pg_catalog.setval('deletion_id_seq', 4, true);
    SELECT pg_catalog.setval('dstpt_id_seq', 10, true);
    SELECT pg_catalog.setval('entity_operations_log_id_seq', 10, false);
    SELECT pg_catalog.setval('etpt_id_seq', 11, true);
    SELECT pg_catalog.setval('event_id_seq', 1, false);
    SELECT pg_catalog.setval('events_search_id_seq', 1, false);
    SELECT pg_catalog.setval('experiment_code_seq', 7, true);
    SELECT pg_catalog.setval('experiment_id_seq', 25, true);
    SELECT pg_catalog.setval('experiment_property_id_seq', 23, true);
    SELECT pg_catalog.setval('experiment_relationships_history_id_seq', 1, false);
    SELECT pg_catalog.setval('experiment_type_id_seq', 3, true);
    SELECT pg_catalog.setval('external_data_management_system_id_seq', 3, true);
    SELECT pg_catalog.setval('file_format_type_id_seq', 8, true);
    SELECT pg_catalog.setval('filter_id_seq', 1, true);
    SELECT pg_catalog.setval('grid_custom_columns_id_seq', 1, false);
    SELECT pg_catalog.setval('locator_type_id_seq', 1, true);
    SELECT pg_catalog.setval('material_id_seq', 3736, true);
    SELECT pg_catalog.setval('material_property_id_seq', 9324, true);
    SELECT pg_catalog.setval('material_type_id_seq', 11, true);
    SELECT pg_catalog.setval('metaproject_assignment_id_seq', 18, true);
    SELECT pg_catalog.setval('metaproject_id_seq', 5, true);
    SELECT pg_catalog.setval('mtpt_id_seq', 31, true);
    SELECT pg_catalog.setval('operation_executions_id_seq', 1, false);
    SELECT pg_catalog.setval('perm_id_seq', 1035, true);
    SELECT pg_catalog.setval('person_id_seq', 21, true);
    SELECT pg_catalog.setval('post_registration_dataset_queue_id_seq', 1, true);
    SELECT pg_catalog.setval('project_id_seq', 7, true);
    SELECT pg_catalog.setval('project_relationships_history_id_seq', 1, false);
    SELECT pg_catalog.setval('property_type_id_seq', 28, true);
    SELECT pg_catalog.setval('query_id_seq', 1, false);
    SELECT pg_catalog.setval('relationship_type_id_seq', 3, true);
    SELECT pg_catalog.setval('role_assignment_id_seq', 29, true);
    SELECT pg_catalog.setval('sample_code_seq', 8, true);
    SELECT pg_catalog.setval('sample_id_seq', 1061, true);
    SELECT pg_catalog.setval('sample_property_id_seq', 55, true);
    SELECT pg_catalog.setval('sample_relationship_id_seq', 48, true);
    SELECT pg_catalog.setval('sample_relationships_history_id_seq', 1, false);
    SELECT pg_catalog.setval('sample_type_id_seq', 12, true);
    SELECT pg_catalog.setval('script_id_seq', 15, true);
    SELECT pg_catalog.setval('semantic_annotation_id_seq', 8, true);
    SELECT pg_catalog.setval('space_id_seq', 3, true);
    SELECT pg_catalog.setval('stpt_id_seq', 21, true);