super-powers/src/f3c04c28-bce4-422e-be93-7d163e4e342b/README.md

230 lines
6.0 KiB
Markdown
Raw Normal View History

2024-04-22 14:43:33 +00:00
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# abstract class Schema (Details)
2024-04-26 09:56:17 +00:00
> namespace: **VDM\Joomla\Abstraction**
2024-04-22 14:43:33 +00:00
```uml
@startuml
abstract Schema #Orange {
# Table $table
# $db
- array $tables
- string $prefix
- array $uniqueKeys
- array $keys
- array $columns
- array $success
2024-04-24 19:22:27 +00:00
# $currentVersion
2024-04-22 14:43:33 +00:00
+ __construct(Table $table)
+ update() : array
# {abstract} getCode() : string
2024-04-24 19:22:27 +00:00
# tableExists(string $table) : bool
+ updateSchema(string $table) : void
+ createTable(string $table) : void
# getExistingColumns(string $table) : array
2024-04-22 14:43:33 +00:00
# addMissingColumns(string $table, array $columns) : void
# checkColumnsDataType(string $table, array $columns) : void
2024-04-24 19:22:27 +00:00
# getColumnDefinition(string $table, string $field) : ?string
# checkDefault(string $table, string $column) : void
2024-04-22 14:43:33 +00:00
# updateColumnsDataType(string $table, array $columns) : void
2024-04-24 19:22:27 +00:00
# getTable(string $table) : string
2024-04-26 09:56:17 +00:00
# isDataTypeChangeSignificant(string $currentType, string $expectedType) : bool
2024-04-24 19:22:27 +00:00
# adjustExistingDefaults(string $table, string $column, ...) : bool
2024-04-22 14:43:33 +00:00
# updateColumnDataType(string $updateString, string $table, ...) : bool
# getTableKeys() : string
2024-04-24 19:22:27 +00:00
# setKeys(array $column) : void
2024-04-22 14:43:33 +00:00
# setUniqueKey(array $column) : void
# setKey(array $column) : void
2024-04-24 19:22:27 +00:00
# getDefaultValue(string $type, ?string $defaultValue, ...) : string
2024-04-22 14:43:33 +00:00
}
note right of Schema::__construct
Constructor.
since: 3.2.1
end note
note left of Schema::update
Check and update database schema for missing fields or tables.
since: 3.2.1
return: array
end note
2024-04-24 19:22:27 +00:00
note right of Schema::getCode
Get the targeted component code
2024-04-22 14:43:33 +00:00
since: 3.2.1
2024-04-24 19:22:27 +00:00
return: string
2024-04-22 14:43:33 +00:00
end note
2024-04-24 19:22:27 +00:00
note left of Schema::tableExists
Check if a table exists in the database.
since: 3.2.1
return: bool
end note
note right of Schema::updateSchema
2024-04-22 14:43:33 +00:00
Update the schema of an existing table.
since: 3.2.1
return: void
end note
2024-04-24 19:22:27 +00:00
note left of Schema::createTable
Create a table with all necessary fields.
2024-04-22 14:43:33 +00:00
since: 3.2.1
2024-04-24 19:22:27 +00:00
return: void
end note
note right of Schema::getExistingColumns
Fetch existing columns from a database table.
since: 3.2.1
return: array
2024-04-22 14:43:33 +00:00
end note
note left of Schema::addMissingColumns
Add missing columns to a table.
since: 3.2.1
return: void
end note
note right of Schema::checkColumnsDataType
Validate and update the data type of existing fields/columns
since: 3.2.1
return: void
end note
2024-04-24 19:22:27 +00:00
note left of Schema::getColumnDefinition
Generates a SQL snippet for defining a table column, incorporating column type,
default value, nullability, and auto-increment properties.
since: 3.2.1
return: ?string
end note
note right of Schema::checkDefault
Check and Update the default values if needed, including existing data adjustments
since: 3.2.1
return: void
end note
2024-04-22 14:43:33 +00:00
note left of Schema::updateColumnsDataType
Update the data type of the given fields.
since: 3.2.1
return: void
end note
2024-04-24 19:22:27 +00:00
note right of Schema::getTable
Add the component name to get the full table name.
2024-04-22 14:43:33 +00:00
since: 3.2.1
2024-04-24 19:22:27 +00:00
return: string
2024-04-22 14:43:33 +00:00
end note
2024-04-24 19:22:27 +00:00
note left of Schema::isDataTypeChangeSignificant
Determines if the change in data type between two definitions is significant.
This function checks if there's a significant difference between the current
data type and the expected data type that would require updating the database schema.
2024-04-26 09:56:17 +00:00
It ignores display width for numeric types where MySQL considers these attributes
irrelevant for storage but considers size and other modifiers for types like VARCHAR.
2024-04-22 14:43:33 +00:00
since: 3.2.1
2024-04-24 19:22:27 +00:00
return: bool
2024-04-22 14:43:33 +00:00
end note
2024-04-24 19:22:27 +00:00
note right of Schema::adjustExistingDefaults
Updates existing rows in a column to a new default value
2024-04-22 14:43:33 +00:00
since: 3.2.1
2024-04-24 19:22:27 +00:00
return: bool
arguments:
string $table
string $column
mixed $currentDefault
mixed $newDefault
2024-04-22 14:43:33 +00:00
end note
2024-04-24 19:22:27 +00:00
note left of Schema::updateColumnDataType
Update the data type of the given field.
2024-04-22 14:43:33 +00:00
since: 3.2.1
2024-04-24 19:22:27 +00:00
return: bool
arguments:
string $updateString
string $table
string $field
2024-04-22 14:43:33 +00:00
end note
2024-04-24 19:22:27 +00:00
note right of Schema::getTableKeys
Key all needed keys for this table
2024-04-22 14:43:33 +00:00
since: 3.2.1
return: string
end note
2024-04-24 19:22:27 +00:00
note left of Schema::setKeys
Function to set the view keys
2024-04-22 14:43:33 +00:00
since: 3.2.1
2024-04-24 19:22:27 +00:00
return: void
2024-04-22 14:43:33 +00:00
end note
2024-04-24 19:22:27 +00:00
note right of Schema::setUniqueKey
Function to set the unique key
2024-04-22 14:43:33 +00:00
since: 3.2.1
2024-04-24 19:22:27 +00:00
return: void
2024-04-22 14:43:33 +00:00
end note
2024-04-24 19:22:27 +00:00
note left of Schema::setKey
Function to set the key
2024-04-22 14:43:33 +00:00
since: 3.2.1
2024-04-24 19:22:27 +00:00
return: void
2024-04-22 14:43:33 +00:00
end note
2024-04-24 19:22:27 +00:00
note right of Schema::getDefaultValue
Adjusts the default value SQL fragment for a database field based on its type and specific rules.
If the field is of type DATETIME and the Joomla version is not 3, it sets the default to CURRENT_TIMESTAMP
if not explicitly specified otherwise. For all other types, or when a 'EMPTY' default is specified, it handles
defaults by either leaving them unset or applying the provided default, properly quoted for SQL safety.
2024-04-22 14:43:33 +00:00
since: 3.2.1
2024-04-24 19:22:27 +00:00
return: string
arguments:
string $type
?string $defaultValue
bool $pure = false
2024-04-22 14:43:33 +00:00
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)