---  ~ Licensed to the Apache Software Foundation (ASF) under one
---  ~ or more contributor license agreements.  See the NOTICE file
---  ~ distributed with this work for additional information
---  ~ regarding copyright ownership.  The ASF licenses this file
---  ~ to you under the Apache License, Version 2.0 (the
---  ~ "License"); you may not use this file except in
---  ~ compliance with the License.  You may obtain a copy of the License at
---  ~
---  ~    http://www.apache.org/licenses/LICENSE-2.0
---  ~
---  ~ Unless required by applicable law or agreed to in writing,
---  ~ software distributed under the License is distributed on an
---  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
---  ~ KIND, either express or implied.  See the License for the
---  ~ specific language governing permissions and limitations
---  ~ under the License.

create table page_template
(
   page_template_id        number(38) not null,
   container_id            number(38) not null,
   name                      varchar2(50) not null,       
   page_layout_id          number(38),   
   default_template        varchar2(1) not null,
   fixed_layout             varchar2(1) not null,
   description      varchar2(200) not null,
   owner_type_code varchar2(5) not null,
   owner_type_value varchar2(50) not null,
   owner_type_url varchar2(200),
   owner_type_logo varchar2(200),
   render_seq       number(10) not null,
   fixed_name       varchar2(1) not null,
   constraint page_template_pk 
        primary key (page_template_id),  
   constraint chk_page_template_dflt
        check (default_template in ('Y','N')),
   constraint chk_page_template_fixed_layout
        check (fixed_layout in ('Y','N')),
    constraint chk_page_template_fixed_name
        check (fixed_name in ('Y','N')),
    constraint unq_page_template_name 
        unique (name)                                     
);


ALTER TABLE page_template
ADD CONSTRAINT page_template_owner_type_fk 
FOREIGN KEY (owner_type_code)
REFERENCES page_template_owner_type(code);