migration - packet
Die nachfolgenden Inhalte sind nur in englischer Sprache verfügbar.
This topic discusses the migration packet API.
All migration packets must be derived from the
BasePacket
class for the framework to execute them.There are several specialized subclasses which facilitate certain types of migration
Classes
BasePacket
Methods
Function | Parameters | Return Value | Description |
---|---|---|---|
BasePacket.__init__ | migrationrule: UUID | Initializes a new packet. If a packet is instanced without a uuid, not all features might work | |
BasePacket.create_migrationrule | override_dict: A dictionary of attributes to pass to | The newly created UUID | Creates a record in table 314 for this migration packet and update the internal state of this instance so that further calls like |
BasePacket.delete | Deletes this migration packet and all history records | ||
BasePacket.delete_log_content | Deletes the currently buffered log and reset the internal logging buffer. This will not delete any logs saved to the database. | ||
BasePacket.fail | reason: A text that describes why the packet failed | Updates the internal state of the packet to mark it as failed. | |
BasePacket.fix | packet_runner: The instance of the migration framework that is running this packet | This method is called by the framework and should contain the code which this packet is supposed to run to migrate the system | |
BasePacket.generate_logfile_name | A name that can be used as a logfile name | Generates a logfile name from the parameters of the packet | |
BasePacket.get_dependencies | A list of dependencies | This method is called by the framework and should return the dependencies of this packet | |
BasePacket.log | text: Log message | Log a message | |
BasePacket.log_heading | text: Log message | Writes a heading in the log. Headings are marked by stars around the text. A value of 0 puts 5 stars around the text, a value of 4 puts 1 star around the text | |
BasePacket.make_active | Called by the framework before execution to initialize the packet logging correctly | ||
BasePacket.mark_as_done | Sets the Erledigt flag to | ||
BasePacket.mark_as_undone | Sets the Erledigt flag to | ||
BasePacket.pending | Sets the packet state to pending. | ||
BasePacket.rollback | This method is called by the framework when a packet fails, so that it can gracefully undo any incomplete changes made to the system. The default implementation simply logs that no rollback action was defined | ||
BasePacket.save_history |
| Creates a new history record in table 315 based on the current execution. The content of the log is written into a hyperlink and the current internal state is saved to Status | |
BasePacket.skip | reason: A text that describes why this packet was skipped | Deprecated | |
BasePacket.success | This method must be called after a packet has migrated the system successfully. | ||
BasePacket.unnecessary | Marks the packet as unnecessary for the current migration. |
Classmethods
Function | Parameters | Return Value | Description |
---|---|---|---|
BasePacket.from_packet_path | packet_path: Python-Pfad | The packet instance or | Search for the migration packet class, initialize it, and set the uuid accordingly |
Properties
Property | Getter | Setter | Description |
---|---|---|---|
BasePacket.__fpath__ |
|
| Returns the path that is saved to Python-Pfad |
BasePacket.__name__ |
|
| The name of the packet class |
BasePacket.component |
|
| Fetches the component of the package that contains the migration packet |
BasePacket.customizing_dependencies_are_met |
|
| Returns wheter the |
BasePacket.dbms_dependency_is_met |
|
| Returns wheter the |
BasePacket.dependencies |
|
| Returns all dependencies of this packet as an iterable oject |
BasePacket.dependencies_are_met |
|
| Returns whether all dependencies are met |
BasePacket.description_long |
|
| Returns the entire docstring |
BasePacket.description_short |
|
| Returns the first sentence of the docstring |
BasePacket.done |
|
| Returns and sets to Erledigt. Note that setting the flag will write log messages to the packets internal logging buffer |
BasePacket.is_failed_or_still_open |
|
| Returns if the |
BasePacket.last_state |
|
| Returns the |
BasePacket.log_content |
| {"status":500,"error":"Internal Server Error","message":null,"timeStamp":"Thu Mar 13 10:15:58 UTC 2025","trace":null} | Returns the content of the internal logging buffer |
BasePacket.logfile_suffix | {"status":500,"error":"Internal Server Error","message":null,"timeStamp":"Thu Mar 13 10:15:59 UTC 2025","trace":null} |
| The file ending for the logfile hyperlink |
BasePacket.maximum_customizing_dependency | {"status":500,"error":"Internal Server Error","message":null,"timeStamp":"Thu Mar 13 10:15:59 UTC 2025","trace":null} |
| Returns the expected version of a |
BasePacket.maximum_customizing_dependency_is_met | {"status":500,"error":"Internal Server Error","message":null,"timeStamp":"Thu Mar 13 10:15:59 UTC 2025","trace":null} |
| Returns whether the |
BasePacket.migrationrule |
| {"status":500,"error":"Internal Server Error","message":null,"timeStamp":"Thu Mar 13 10:15:58 UTC 2025","trace":null} | |
BasePacket.minimum_customizing_dependency | {"status":500,"error":"Internal Server Error","message":null,"timeStamp":"Thu Mar 13 10:15:59 UTC 2025","trace":null} | {"status":500,"error":"Internal Server Error","message":null,"timeStamp":"Thu Mar 13 10:15:58 UTC 2025","trace":null} | Returns the expected version of a |
BasePacket.minimum_customizing_dependency_is_met | {"status":500,"error":"Internal Server Error","message":null,"timeStamp":"Thu Mar 13 10:15:59 UTC 2025","trace":null} |
| Returns wheter the |
BasePacket.packet_dependencies_are_met |
| {"status":500,"error":"Internal Server Error","message":null,"timeStamp":"Thu Mar 13 10:15:59 UTC 2025","trace":null} | Returns whether all |
BasePacket.pythonpath |
|
| |
BasePacket.release | {"status":500,"error":"Internal Server Error","message":null,"timeStamp":"Thu Mar 13 10:16:00 UTC 2025","trace":null} |
| Gets the release from the package this migration packet is part of |
BasePacket.release_version | {"status":500,"error":"Internal Server Error","message":null,"timeStamp":"Thu Mar 13 10:16:00 UTC 2025","trace":null} |
|
|
BasePacket.twiki_url |
|
| Returns the url to the ReleaseNotes topic where this packet is described |
SucceedOldPacket
SucceedOldPacket
provides a method for easily setting the Erledigt flag on other packets.
It is used to mark packets which are superseded by a more recent packet as done, regardless of whether they succeeded before or not
Methods
Function | Parameters | Return Value | Description |
---|---|---|---|
SucceedOldPacket.mark_packet_as_done | packet_path: The Python-Pfad of a packet |
| Marks the packet with the specified Python-Pfad as done. If no packet with that path exists, no error will be raised |
ChangeDTPPacket
ChangeDTPPacket
provides methods for changing values on dtp level
All methods log intensively to assist with debugging
Methods
Function | Parameters | Return Value | Description |
---|---|---|---|
ChangeDTPPacket.change_value | record: A |
| Changes a value on a data item if the system matches the expected state. This method returns |
ChangeDTPPacket.get_record | dt_num: DT |
| A wrapper around |
ChangeDTPPacket.verify_value | record: |
| Verifies that a dataitem matches a certain ex |
SQLPacket
The SQLPacket
is designed to execute sql files and make changes to the database
select_and_log()
andmodify_and_log()
should be used over callingdb_select()
anddb_modify()
directly, as theSQLPacket
methods provide useful logging
Methods
Function | Parameters | Return Value | Description |
---|---|---|---|
SQLPacket.apply_dml_file | sql_dialect: | Applies an sql file from the current folder to the database. The sql files should have a suffix like | |
SQLPacket.apply_fix_ddl_file | sql_dialect: | Works like | |
SQLPacket.get_queries_from_file | file_path: The path to a file containing SQL statements | A list of statements | Reads the file at the given path and extract the queries. When |
SQLPacket.get_sql_file_path | sql_dialect: | Filename with added suffix | Returns the path to the given file name with an added suffix |
SQLPacket.select_and_log | query: A select statement | Result of the select | Logs and executes a select. When |
Staticmethods
Function | Parameters | Return Value | Description |
---|---|---|---|
SQLPacket.alter_precision_of_numeric_column | table_name: Variablenname |
| Alters the precision of a numeric column. When |
SQLPacket.column_allows_null | table_name: Variablenname |
| Checks whether a column allows |
SQLPacket.column_exists | table_name: Variablenname |
| Checks whether a column exists |
SQLPacket.columns_have_index_already | table_name: Variablenname |
| Checks whether a bunch of columns have an index spanning across them |
SQLPacket.constraint_exists | table_name: Variablenname |
| Checks whether a constraint exists |
SQLPacket.drop_column | table_name: Variablenname | Drops a column. Returns | |
SQLPacket.drop_constraint | table_name: Variablenname | Drops a constraint if it exists | |
SQLPacket.drop_index | table_name: Variablenname | Drops a index if it exists | |
SQLPacket.get_char_length_of_varchar_column | table_name: Variablenname | Maximum number of characters | Gets the maximum number of characters for a varchar column. |
SQLPacket.get_column_type | table_name: Variablenname | A column type like | Gets the column type of the given column in upper case |
SQLPacket.get_constraints_of_column | table_name: Variablenname | List of constraint names | Gets the constraints of the column |
SQLPacket.get_default_value_for_column | table_name: Variablenname | Default value or | Gets the default value of a column. Returns |
SQLPacket.get_indices_of_column | table_name: Variablenname | List of index names | Gets the indices this column is used in |
SQLPacket.get_precision_and_scale_of_column | table_name: Variablenname | Tuple of (precision, scale) | Gets the column precision and scale if applicable |
SQLPacket.get_varchar_column_type | table_name: Variablenname | 'B' or 'C' | Gets the varchar column type. Returns B for bytes and C for char. |
SQLPacket.index_exists | table_name: Variablenname |
| Checks whether a given index exists |
SQLPacket.is_nullable | table_name: Variablenname |
| Checks whether a column allows null values. Returns None if the table/column pair does not exist |
SQLPacket.modify_and_log | query: Sql statement | Number of rows affected | Executes an sql statement on the database. If |
SQLPacket.move_table_to_different_schema | table_number: DT |
| Moves a table to a different schema. If the table has hyperlinks, this will raise a |
SQLPacket.object_is_materialized_view | object_name: SQL name |
| Checks whether a materialized view with the given name exists. Note that materialized views do not exist in MSSQL. |
SQLPacket.object_is_table | object_name: SQL name |
| Checks whether a table with the given object name exists |
SQLPacket.procedure_exists | procedure_name: SQL name |
| Checks whether a given procedure exists. |
SQLPacket.remove_constraints_from_column | table_name: Variablenname | Removes all constraints from the column | |
SQLPacket.remove_customizing_for_column | table_name: Variablenname |
| Removes all customizing records that use the dataitem associated with the table/column pair. |
SQLPacket.table_exists | table_name: Variablenname |
| Checks whether a table with the given object name exists |
SQLPacket.rename_table | old_table_name: Variablenname |
| Renames a table on the database. |
SQLPacket.rename_column | table_name: Variablenname |
| Renames a column in a table. |