FOSSology
3.2.0rc1
Open Source License Compliance by Open Source Software
|
Class to handle database schema. More...
Public Member Functions | |
__construct (DbManager &$dbManager) | |
setDriver (Driver &$dbDriver) | |
applyOrEchoOnce ($sql, $stmt= '') | |
applySchema ($filename=NULL, $debug=false, $catalog= 'fossology', $migrateColumns=array()) | |
Make schema match $Filename. This is a single transaction. More... | |
applySequences () | |
Add sequences to the database. More... | |
applyClusters () | |
Add clusters. More... | |
updateSequences () | |
Add sequences. More... | |
applyTables ($inherits=false) | |
Add tables/columns (dependent on sequences for default values) More... | |
applyViews () | |
dropConstraints () | |
Delete constraints. More... | |
dropIndexes () | |
applyIndexes () | |
applyConstraints () | |
dropViews ($catalog) | |
Delete views. More... | |
dropColumnsFromTable ($columns, $table) | |
getCurrSchema () | |
Load the schema from the db into an array. | |
addInheritedRelations () | |
addTables () | |
addViews ($viewowner) | |
addSequences ($referencedSequencesInTableColumns) | |
addConstraints () | |
addIndexes () | |
addFunctions ($schema) | |
writeArrayEntries ($fout, $key, $value, $varname) | |
exportSchema ($filename=NULL) | |
Export the schema of the connected ($PG_CONN) database to a file in the format readable by GetSchema(). More... | |
makeFunctions () | |
Create any required DB functions. | |
applyInheritedRelations () | |
Public Attributes | |
$debug = false | |
Private Attributes | |
$dbman | |
$schema = array() | |
$currSchema = array() | |
Class to handle database schema.
Definition at line 39 of file libschema.php.
fo_libschema::__construct | ( | DbManager & | $dbManager | ) |
Constructor for fo_libschema
DbManager | $dbManager |
Definition at line 69 of file libschema.php.
fo_libschema::addConstraints | ( | ) |
Add constraints to the current schema
Definition at line 672 of file libschema.php.
fo_libschema::addFunctions | ( | $schema | ) |
Add functions to the given schema
array | $schema | Schema in which the functions are to be added |
FUNCTION
key Definition at line 855 of file libschema.php.
fo_libschema::addIndexes | ( | ) |
Add indexes to the current schema
Definition at line 828 of file libschema.php.
fo_libschema::addInheritedRelations | ( | ) |
Add inherited relations to the current schema.
Definition at line 531 of file libschema.php.
fo_libschema::addSequences | ( | $referencedSequencesInTableColumns | ) |
Add sequences to the current schema
array | $referencedSequencesInTableColumns | Array from addTables() |
Definition at line 635 of file libschema.php.
fo_libschema::addTables | ( | ) |
Add tables to the current schema
Definition at line 550 of file libschema.php.
fo_libschema::addViews | ( | $viewowner | ) |
Add views to the current schema
string | $viewowner | Owner of the view |
Definition at line 618 of file libschema.php.
fo_libschema::applyClusters | ( | ) |
Add clusters.
The function first checks if the cluster already exists or not. The cluster is only created only if it does not exists.
Definition at line 224 of file libschema.php.
fo_libschema::applyConstraints | ( | ) |
Add constraints (dependent on columns, views, and indexes)
Definition at line 427 of file libschema.php.
fo_libschema::applyIndexes | ( | ) |
Add indexes (dependent on columns)
Definition at line 400 of file libschema.php.
fo_libschema::applyInheritedRelations | ( | ) |
Apply inherits relations from schema on DB
Definition at line 1015 of file libschema.php.
fo_libschema::applyOrEchoOnce | ( | $sql, | |
$stmt = '' |
|||
) |
Apply or echo the SQL statement based on the debugging status.
string | $sql | Statement to be applied |
string | $stmt | Name of the statement (for caching) |
Definition at line 90 of file libschema.php.
fo_libschema::applySchema | ( | $filename = NULL , |
|
$debug = false , |
|||
$catalog = 'fossology' , |
|||
$migrateColumns = array() |
|||
) |
Make schema match $Filename. This is a single transaction.
string | $filename | Schema file written by schema-export.php |
bool | $debug | Turn on debugging (echo sql as it is being executed) |
string | $catalog | Optional database name |
array[] | $migrateColumns array('tablename'=>array('col1','col2'),...) of columns which should not be deleted |
Definition at line 108 of file libschema.php.
fo_libschema::applySequences | ( | ) |
Add sequences to the database.
The function first checks if the sequence already exists or not. The sequence is only created only if it does not exists.
Definition at line 201 of file libschema.php.
fo_libschema::applyTables | ( | $inherits = false | ) |
Add tables/columns (dependent on sequences for default values)
The function creates new tables in the database. The function also drops columns which are missing from schema and add new columns as well.
Definition at line 270 of file libschema.php.
fo_libschema::applyViews | ( | ) |
Add views (dependent on columns)
Definition at line 326 of file libschema.php.
fo_libschema::dropColumnsFromTable | ( | $columns, | |
$table | |||
) |
Delete columns from tables
array | $columns | Name of columns to be dropped |
string | $table | Name of the table |
Definition at line 494 of file libschema.php.
fo_libschema::dropConstraints | ( | ) |
Delete constraints.
Delete now, so they won't interfere with migrations.
Definition at line 348 of file libschema.php.
fo_libschema::dropIndexes | ( | ) |
Delete indexes
Definition at line 378 of file libschema.php.
fo_libschema::dropViews | ( | $catalog | ) |
Delete views.
Get current tables and columns used by all views. Delete if: uses table I know and column I do not know. Without this delete, we won't be able to drop columns.
string | $catalog | Name of the catalog |
Definition at line 465 of file libschema.php.
fo_libschema::exportSchema | ( | $filename = NULL | ) |
Export the schema of the connected ($PG_CONN) database to a file in the format readable by GetSchema().
string | $filename | Path to the file to store the schema in. |
Definition at line 912 of file libschema.php.
fo_libschema::setDriver | ( | Driver & | $dbDriver | ) |
Set the Driver for the DbManager
Driver | $dbDriver |
Definition at line 78 of file libschema.php.
fo_libschema::updateSequences | ( | ) |
Add sequences.
The function executes the UPDATE statement of the sequence.
Definition at line 248 of file libschema.php.
fo_libschema::writeArrayEntries | ( | $fout, | |
$key, | |||
$value, | |||
$varname | |||
) |
Write array entries to $fout as string representation
resource | $fout | |
string | $key | |
array | $value | |
string | $varname |
Definition at line 890 of file libschema.php.
|
private |
Current schema of the DB
Definition at line 63 of file libschema.php.
|
private |
DB manager to use
Definition at line 51 of file libschema.php.
bool fo_libschema::$debug = false |
Set true to enable debugging
Definition at line 45 of file libschema.php.
|
private |
Schema to be applied
Definition at line 57 of file libschema.php.