304
edits
m (→Foreign keys) |
|||
| Line 151: | Line 151: | ||
== DDL file format == | == DDL file format == | ||
Files | Files containing definition of the database object/structure (DDL files) must be 2 per tables: | ||
* Each table is defined by its own file whose name is <tt>llx_''mytable''.sql</tt> | * Each table is defined by its own file whose name is <tt>llx_''mytable''.sql</tt> | ||
A comment will be added | A comment will be added for each field to explain its usage. | ||
* All foreign keys, performance indexes or other constraints will be defined | * All foreign keys, performance indexes or other constraints will be defined in another file called <tt>llx_''mytable''.key.sql</tt> | ||
These files must be stored in the directory '''install/mysql/tables''' for all standard files or '''mymodule/tables''' for tables provided by an external module. | |||
Example '''file | Example '''file for table llx_mytable.sql''': | ||
<source lang="sql"> | <source lang="sql"> | ||
| Line 196: | Line 196: | ||
</source> | </source> | ||
Example '''file for keys/ | Example '''file for keys/indexes will be llx_mytable.key.sql''': | ||
<source lang="sql"> | <source lang="sql"> | ||
| Line 216: | Line 216: | ||
-- =========================================================================== | -- =========================================================================== | ||
ALTER TABLE | ALTER TABLE llx_mytable ADD UNIQUE uk_mytable_field (field_one, field_two); | ||
ALTER TABLE | ALTER TABLE llx_mytable ADD CONSTRAINT fk_mytable_fk_field FOREIGN KEY (fk_field) REFERENCES llx_matablepere (rowid); | ||
</source> | </source> | ||
edits