Trying to remain DRY...

Our template for new tables looks like this (we are an Oracle shop).
"**" is replaced with the full name, the "@@" with the abbreviation.
/
*********************************************************************************/
/*
 * Contact Center Schema Script
 *
 * Object Type: Table
 * Object Name: **
 * Purpose:
 *
 * Change Log:
 *      <date>  <user>    Created
 */

-- CONNECT AS VRUCLAIMS ;

declare
    x varchar2(30);
begin
    select table_name into x from user_tables where table_name =
'CCT_**' ;
    if x is not null then
        execute immediate 'drop table CCT_** cascade constraints';
        execute immediate 'drop sequence CCT_**_SEQ' ;
    end if;
    EXCEPTION WHEN NO_DATA_FOUND THEN
        DBMS_OUTPUT.PUT_LINE('No need to drop table.');
end;
/

-- PRIMARY KEY SEQUENCE (if not created in separate file)
-- (MAXVALUE SET BEC. KEY VALUES ARE 10 DIGITS WIDE)
CREATE SEQUENCE CCT_**_SEQ START WITH 1 MAXVALUE 9999999999 ;


CREATE TABLE CCT_**
(
      **_ID               NUMBER( 10,0 )
    , @@_UPDATE_DATE         DATE            DEFAULT SYSDATE NOT
NULL
    , @@_UPDATE_USER         VARCHAR2( 30 )  DEFAULT USER    NOT NULL
-- CONSTRAINTS
    , CONSTRAINT PK_@@ PRIMARY KEY (**_ID)
-- FK:
    , CONSTRAINT FK_@@_USER FOREIGN KEY ( @@_UPDATE_USER ) REFERENCES
CCT_USER ( USERNAME )
-- CHECKS:
    --, CONSTRAINT CHK_@@_UPDT CHECK (@@_UPDATE_DATE >= SYSDATE -1 )
)
-- PHYS ATTRIBS
        PCTFREE 5
        INITRANS 2
STORAGE
(
    INITIAL
        -- ( ROWSIZE * NUMBER OF ROWS ) + BUFFER
        PCTINCREASE 0
        FREELISTS 15
        -- MAKE LOWER FOR FEWER CONCURRENT UPDATES
)
  PARALLEL
-- TABLESPACE xx
    ;

-- ANCILLARY INDEXES
--CREATE INDEX IDX_@@_ ON CCT_** ( @@_ ) ;

-- FK INDEXES
CREATE INDEX FKI_@@_USER ON CCT_** ( @@_UPDATE_USER )  USING INDEX
TABLESPACE IDX_01;

/
*********************************************************************************/

I've seen that I can do most of this in the Python model, but there
are a couple critical gaps that I'd really like to find a way to
fill.  For example, everything after the column list (the physical
characteristics of the table) is something I do not want to lose
control of.  How can I do this in django's model.py?

I've read about the arbitrary post-creation sql and the database-
specific code files, but the physical parameters should really be part
of the CREATE statement, not post-creation modify statements.  I will
verify that they cannot be done afterwards.

Failing the ability to modify the django tools to do this, is there a
way to reverse-engineer a model from existing tables?  This may
actually be the better way to go, as I don't guess our DBA's will know
what to do with model.py files...

Thanks,
Chris

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to