Methodology for reinstalling the K2 program
Introduction
You will become familiar with the graphical form of the individual reinstallation steps in the form of a diagram.
Glossary of terms
Reinstall manager is a K2 function that helps with the reinstallation of K2.
Licence administration is a K2 function that is used in this document for remotely logging users off from K2.
SQL Server Management Studio (SSMS) is a Microsoft® product used to manage MS SQL servers and databases.
Oracle SQL Developer is an Oracle Corporation® product used to manage Oracle servers and databases.
Build-type reinstallation – minor is a type of reinstallation where only the last version number, the so-called build, changes. Conceptually, this type is intended to deal only with bug fixes and the addition of minor improvements. This reinstallation should not endanger existing functionality. No identifiers used in scripts are removed unless they are evaluated as erroneous. An example would be a failure to cancel an identifier when moving to a higher release or generation version. Its use could then lead to unwanted behaviour or an algorithm error.
Release-type reinstallation – medium is a type of reinstallation where the middle version number, the so-called release, changes. New functionality can be added to individual releases. The same rules apply as for the previous "minor" reinstallation, with the difference that it is advisable to perform a test reinstallation first, followed by testing of the key K2 functions, before the reinstallation itself.
Generation-version reinstallation – major is a type of reinstallation where the first version number changes. This is a fundamental change in which completely new functionality is added to K2, or existing functionality is fundamentally reworked or removed. This type always requires a reinstallation in a test environment, because situations may arise, especially during conversions, that cannot be reliably handled under laboratory conditions during development. The reinstallation of the production K2 is therefore first performed in a test environment, where the test folder is taken over, and after all conversions and functions have been tested and debugged, the reinstallation of the production K2 is performed.
Application server (AS) is a non-visual extension of K2 that performs automatic tasks and scheduled tasks, communicates with other K2 products, e.g. the web services server (K2 API), serves the web client, etc.
Taking over an existing installation is a state where the K2 folder is used for a new installation. This situation should not normally occur, because the Windows installation mechanism keeps all msi files from which it performed the installation in system folders, as well as the information in the registry, until the program is uninstalled. Logically, it follows that constantly taking over one K2 will clutter the registry and the space on the system disk will decrease by the size of the msi file with each reinstallation. Another consequence is that installation records multiply in the K2 installer records, even though it is only one K2. The maximum number of records for K2 instances is 100, after which no more instances can be added.
When to use a takeover?
- If we are creating a test environment and copying the complete production K2 to a new folder.
- We are performing the installation from a different computer than before. Even so, care must be taken, because installation from multiple computers in a network environment can cause file inconsistency.
- After the removal of the original K2 fails during reinstallation.
- If an error occurred during the installation phase of the reinstallation and the installation ends unexpectedly.
Creating a test environment for reinstallation
A test environment can be created in several ways so that reinstallation can be performed in the given folder. The minimum condition for a folder to be considered K2 is the presence of the k2.ini and sysk2.ini files, with the data in them referring to an existing server and database. However, an optimally prepared test environment is created by making a copy of the live databases on the database servers (this can be within one SQL server or the data can be transferred to another one), copying the live K2 folder to a new folder and overwriting the reference to the database, or the server, in k2.ini. A copy created in this way is identical to the live K2, and therefore all possible problems can be solved before the live K2 is reinstalled. Data adjustments that must be made during the test reinstallation, e.g. so that conversions run without errors, can be made, and it is even recommended, in parallel both in the test and in production.
When creating a test K2, it is good to consider whether all databases or schemas need to be transferred. For a test reinstallation, it is advisable to use only the databases of the live Clients. It is not necessary to copy the DEMO, INIT or any test Clients. For example, the live K2 contains the following Clients: DEMO (demonstration database supplied by K2), INIT (demonstration database supplied by K2), FIRMA (production database), FIRMA2 (production database of another company or branch), FIRMA2_TEST (test database created by copying FIRMA2). In this case, only FIRMA and FIRMA2 are used for test purposes. The other databases are not needed. However, if only some databases are copied, the FIRMY table in the configuration database must be adjusted. This can be done either by directly modifying the tables using SQL queries, or by modifying the table with a tool, e.g. SSMS, or in the database administration in K2. It is important that the companies table contains only records corresponding to the databases used in the test.
Reinstallation procedure
Scheme
The scheme is designed so that it can be applied to every situation in which K2 needs to be reinstalled.
Picture: K2 reinstallation scheme
In its main branch, the scheme shows a reinstallation without any problems on an installed K2.
Other branches, which you will find in the chapters Check of mandatory version initializations, Check of structures of all databases and Extensions update, come into play in some non-standard situation.
Colours and shapes of blocks in the scheme
|
Beginning or end of a scheme or subscheme. |
|
Decision block, where the scheme branches according to a given condition. |
|
Process block. Execution of a certain action. |
|
Subprocess block. A subprocess contains a subscheme that contains several actions. |
|
Pointer of the direction of the scheme flow, including the result of the decision when this branch is followed. |
Use of the scheme
In its main branch, the scheme shows a reinstallation without any problems on an installed K2.
Other branches come into play in some non-standard situation. Non-standard situations are understood to be when the reinstallation was performed only partially, a problem occurred during the removal of the previous version, a copy of the production K2 was created for the purpose of testing the reinstallation, etc.
Individual reinstallation steps
For the diagram to be complete, it is necessary to explain each step of the reinstallation itself. You will learn what must be done at the individual levels, what the options for solving problems are, or where to find supporting resources to solve a problem.
Decision: Is an executable K2 available?
Decides: IS K2 administrator
Description: An executable K2 is understood as the state when a complete K2 is located in the folder, which can be started and worked in. At this point, it does not matter whether the folder was created by installation or copied from the production K2 as a copy. If K2 is executable, we continue with the point Scheduling the reinstallation; if not, we continue with the point Decision: The databases match the installed K2 version.
Scheduling the reinstallation
Location: K2 information system
Run: IS K2 administrator
Permission: Right – Administrator/General/Service operations (right number 1)
Condition: Optional action, this is a manufacturer's recommendation
Description: At the time of reinstallation, no users may be logged in to K2, so that no conflicts can occur when writing files or changing data after the backups and the entire preparation for reinstallation have been made. To avoid unnecessary problems with logged-in users in the period before reinstallation, the date and time of the reinstallation can be scheduled directly in K2. This functionality ensures that from the set date, no one except the user who set this state logs in to K2. Users who log in before the date are warned that a reinstallation will take place from a certain date.
The "Reinstall manager" tool is used in K2 to schedule a reinstallation. It is available in the tree "Administrator / System / Reinstall manager" or as function number 753.

Picture: Reinstall manager
After checking the "Login prohibited" option, the date, time and message to be displayed to users who want to log in to K2 are set.

Picture: Setting the reinstallation date and time
On a subsequent login attempt, users are shown the message that is set in the Reinstall manager. This message can be changed as required. If the date and time from need to be displayed, %s is added to the text, which is automatically replaced in the message with the value from the Login prohibited from field.

Picture: Message about a scheduled reinstallation
Scheduling the reinstallation of Web K2
In the case of a reinstallation or other intended outage of web K2, the administrator can manually set a page saying that maintenance is in progress on the web. Web K2 can be set in the web.config file, in the element <rule name="Site Maintenance" enabled="false" stopProcessing="true">, by changing the attribute enabled="false" to the value enabled="true".

Picture: Web K2 maintenance page
Log out all users
Location: K2 information system
Run: IS K2 administrator
Permission: Right – Administrator/General/Service operations (1)
Condition: Mandatory action – reinstallation is not possible if users are logged in to K2
Description: Before the reinstallation itself, all K2 users must be logged off. Their list and the option to log them off can be found in "Licence administration", which is available in the menu "Administrator / System / Licence administration" or as function number 678.

Picture: Licence administration and logged-in users
To log off a user, we open the record detail and press the "Log off" button. This can advantageously be used to terminate running application servers without having to connect to the computers where the AS is running.

Picture: Users logged off from K2
Note
It is up to the administrator to decide whether to disconnect the users directly from the form or to find out personally from each of them whether they have any record in progress. Pressing the "Log off" button logs the user off without saving records in progress.
A situation may occur where the user cannot be logged off under any circumstances and, moreover, it is found that the user definitely does not have K2 running. In such a case, it is necessary to "kill" the session on the SQL server. To find users on MS SQL, the sp_who command is used, which prints a table with the existing connections to the server.

Picture: List of connections to the MS SQL server
To terminate the relevant connection, it is necessary to know to which database the user who has not been logged off connects. Usually, there are one or two records in the list, depending on how many connections remained "hanging". The important columns are spid, status, loginame, hostname, dbname and cmd. The spid column is the connection number, which we need to know to terminate it, status is the connection state, loginame is the user under which K2 logs in to the database, hostname is the name of the computer from which K2 is or was started, dbname is the name or names of the databases to which K2 is connected, and cmd is the command currently being executed. For a safe termination of the login, the status column should be in the sleeping state and cmd in AWAITING COMMAND. The other columns listed above must correspond to the login data and names of the user who has not been logged off, so that we disconnect the correct connection. The kill command is used for this, followed by the number of the connection we want to terminate: kill 64.
On Oracle, the following queries are used:
select SID, SERIAL#, CLIENT_INFO, TERMINAL, LOGON_TIME FROM "SYS"."GV_$SESSION"
where USERNAME='K2' AND REGEXP_LIKE("CLIENT_INFO", 'K2/./.*/.*/.*/.*/.*')
order by TERMINAL
and
alter system kill session '19,46574';
In the kill command, the session values are 'SID,SERIAL#' .
Backup of all databases
Location: Database administration tool (SQL Server Management Studio)
Run: IS K2 administrator
Permission: According to the permissions set on the SQL server
Condition: Optional action, this is a manufacturer's recommendation
Description: Before each reinstallation, the administrator should back up all databases affected by the reinstallation. These are the K2 system database – CONF and all company databases. Other databases such as INIT and DEMO do not need to be backed up. The backups can then be used if an error occurs during the reinstallation that makes it necessary to return the K2 installation to its original state before the reinstallation. When it is necessary to restore the backup will be described in the further reinstallation steps.
Note
We use various client tools for database operations. In the case of Microsoft, it is recommended to use Microsoft SQL Server Management Studio (SSMS). In the case of Oracle, data pumps or Oracle Recovery Manager (RMAN), for example, are used.
Reinstall manager - reinstallation preparation

Picture: Pre-installation preparation
Location: K2 information system
Run: IS K2 administrator
Permission: Right – Administrator/General/Service operations (1)
Condition: Mandatory action – reinstallation is not possible if K2 is not set to reinstallation mode
Description: The Reinstall manager is primarily used to set K2 to the so-called reinstallation mode. This is a state in which it is ensured that no users are logged in to K2, new ones cannot log in either, and furthermore K2 has passed all the checks implemented for the given version. The individual operations performed in the Reinstall manager are described in the following chapters.
Has it been performed?
First of all, it is necessary to check whether the so-called "Pre-installation preparation" exists in the initial version. These are operations that must be performed before the reinstallation itself to a higher generation version. If the preparation is not performed, it is not possible to continue with the reinstallation.
If a higher generation version is not going to be installed, the pre-installation preparation is not run!
Note
If a pre-installation preparation exists, there is a button with this information on the form.

Picture: Reinstall manager - Pre-installation preparation
If a pre-installation preparation exists and has not been performed, we continue with the following point Performing pre-installation preparations. If it does not exist, we can continue with the point Check of mandatory version initializations for all databases.
Performing the pre-installation preparation
Location: K2 information system
Run: IS K2 administrator
Permission: Right – Administrator/General/Service operations (1)
Condition: Mandatory action when moving to a higher generation version – the reinstallation mode cannot be set if it has not been performed
Description: If a pre-installation preparation exists, it must be applied to the initial version. Pressing the button displays a form with more detailed information, or inputs for the preparation.

Picture: Example of a pre-installation preparation
Note
Successful completion of the pre-installation preparation is one of the conditions for moving to a higher generation version and is checked only by the installer, because only the installer knows for sure how "big" the reinstallation is.
Check of mandatory version initializations across all databases

Picture: Check of mandatory version initializations
Location: K2 information system
Run: Runs automatically
Permission: Right – Administrator/General/Service operations (1)
Condition: Mandatory action – the reinstallation mode cannot be set if not all mandatory initializations have been performed in all Clients except DEMO and INIT.
Description: When the administrator tries to check the "Reinstallation enabled" option, thereby setting K2 to the so-called reinstallation mode, K2 automatically checks whether all mandatory initializations have been performed in all Clients. If the mandatory initializations also include a repair of structures and there is an error in the DEMO or INIT Client that appears during the structure check, the repair can be made by recreating the relevant databases with the Database button on page 2 of the Client administration.
Have the mandatory initializations been performed?
If the check finds that the initializations have been performed, we continue with the step Check of structures of all databases.
If they have not been performed, we continue with the step Performing mandatory initializations in Clients where they are missing.

Picture: Check for mandatory initializations
Performing mandatory initializations in Clients where they are missing
Location: K2 information system
Run: IS K2 administrator
Permission: Right – Administrator/General/Initialization of versions (755)
Condition: Mandatory action – the reinstallation mode cannot be set if not all mandatory initializations have been performed
Description: Running the mandatory initializations is available in the menu "Administrator / Initialization of versions" or using function 552. Then we continue in the form by pressing the "Required" button. After the initialization has completed successfully, we can return to the step Check of mandatory version initializations across all databases, which performs the check again.

Picture: Running the mandatory initialization
Note
If the initialization does not complete correctly, the problem must be reported to K2. For a faster solution of the problem, it is advisable to log the error to a file according to the instructions in the K2 technical documentation. In some cases, there may be an error in the initialization that is fixed in a higher build version. If it is a build-type reinstallation, the missing initialization can be ignored, because the error is fixed and the initialization will be performed during the reinstallation. Ignoring the check is up to the user, because the user knows that the reinstallation will not be to a higher release or generation version. If the check is ignored and a reinstallation to a higher release or generation version is nevertheless performed, the installer will warn about this situation and will no longer allow it to be ignored.
Check of structures of all databases

Picture: Database structure check
Location: K2 information system
Run: IS K2 administrator
Permission: Right – Administrator/General/Service operations (1)
Condition: At this point, this is an optional action, i.e. K2 can be set to reinstallation mode without running it. Since this action also runs during the reinstallation itself and does not allow the user to continue in the event of errors, it is advisable to perform the check here as well, to avoid delays during the reinstallation itself. This action can also be run during normal K2 operation, even before logins are prohibited.
Description: After starting, a consistency check of the structures of all databases of the current K2 is performed. That is, the K2 configuration database (CONF), the initialization database (INIT), the demonstration company (DEMO) and also all company databases. The check means a comparison of the structures that the current K2 installation expects with the existing structures. The operation runs in parallel on up to eight databases. A separate K2 process that performs the structure check is started for each of them. The speed of the check depends on the platform, the number of databases checked, the performance of the database server, the network, etc.
Is the database consistent?
If the check has passed and there are no inconsistencies in the structure, the reinstallation continues with the point - Backup of all databases 2.
Note
A database inconsistency can be recognized from the output log. If it contains errors, a K2 window or a text file is displayed, depending on where the check is started from, listing all detected deficiencies.
If inconsistencies are found, we continue with the next step - Repair of database inconsistencies.
Repair of database inconsistencies
Location: SQL server administration
Run: IS K2 administrator
Permission: Administrator permission for database administration on the SQL server
Condition: Mandatory operation. If there are database inconsistencies, it is not possible to continue with the K2 reinstallation.
Description: The following problems may be detected during the check:
Existence of tables: If a table required by K2 is missing in the database, this fact is logged and displayed to the user. The message may look as follows:

Picture: Missing table in the database
The missing table can be created depending on its origin.
If it is a special (customer) table created in the Object designer, the "Deploy" operation must be performed in the given project, which ensures that the tables that do not exist are created.
If it is a standard table, it is necessary to find the "SQL" directory in the K2 installation directory, in which the scripts for creating the database structures are stored. To obtain the script for creating the missing table, it is necessary to open the file "K2t_{Typ}_{Platforma}.SQL", where "{Typ}" indicates whether it is the "CONF" database or a company database, and "{Platforma}" indicates whether it is a Microsoft or Oracle database. In the file, it is then necessary to find the construct "CREATE TABLE table_name", which we run on the given SQL server, for example using the SSMS tool. The script may look as follows:
CREATE TABLE [dbo].[FILTERSTOCKTAKINGARTICLE] (
[FUzivatel] [int] NOT NULL,
[Cis] [int] NOT NULL,
[Zkr] [varchar] (30) NOT NULL,
[Zkr1] [varchar] (30) NOT NULL,
[Naz] [varchar] (200) NOT NULL
)
GO
ALTER TABLE [dbo].[FILTERSTOCKTAKINGARTICLE] With NOCHECK ADD
CONSTRAINT [FSTTA_ById] PRIMARY KEY NONCLUSTERED
([FUzivatel], [Cis]) ON [PRIMARY]
GO
CREATE UNIQUE INDEX [FSTTA_ByAbbr] ON [dbo].[FILTERSTOCKTAKINGARTICLE]
([FUzivatel], [Zkr])
ON [PRIMARY]
GO
CREATE UNIQUE INDEX [FSTTA_ByAbbr1] ON [dbo].[FILTERSTOCKTAKINGARTICLE]
([FUzivatel], [Zkr1], [Cis])
ON [PRIMARY]
GO
CREATE UNIQUE INDEX [FSTTA_ByName] ON [dbo].[FILTERSTOCKTAKINGARTICLE]
([FUzivatel], [Naz], [Cis])
ON [PRIMARY]
GO
Existence of fields in tables
The consistency test checks whether the database table contains the fields according to the definition. If a field is missing in the table or is redundant, this fact is displayed to the user.
Missing field in a table
In the case of a missing field, a message is displayed to the user, which may look as follows:

Picture: Missing field in a database table
The table can be repaired depending on its origin.
If it is a special (customer) table created in the Object designer, the "Deploy" operation must be performed in the given project, which ensures that the field is added to the given table.
If it is a standard table, it is very likely that the field is missing because one of the conversions was not completed correctly during reinstallations to newer versions in the past. In these cases, it is possible to examine the conversion scripts of the current K2 installation. The scripts are located in the K2 installation directory in the "SQL\konverze" subdirectory. There is a set of files here that are used during reinstallation to the current version. The files are divided according to the database platform and also according to the database type – CONF / company. The syntax is as follows – "K2_{typ}{verze}{platforma}.sql", where "typ" is "C" for the configuration database (CONF) and "D" for company databases. "Verze" indicates the number of the version for which the conversions are intended. "Platforma" is in the form "Ora" for an Oracle database or without text for a Microsoft SQL database. There are also files with the postfix "Additional" here, which are the so-called additional conversions.
In these files, it is necessary to find the script that adds the missing field. It can then be run in the database administration tool. Together with the script that adds the field, it is also necessary to run any script that may, for example, fill in the values of this field, convert data from another table, etc. If the administrator is not sure which script to run or cannot find it in the given files, it is necessary to contact the K2 technical department and request a repair script. The result of the check and the current version of the K2 system must always be attached.
Note
Additional conversions are run during every reinstallation, even in the case of a build reinstallation within the same release, the so-called minor reinstallation – bug fixes. The other files, without additional, are run only once, when moving from a lower generation version to a higher one. For example, K2 mona › K2 mia.
Redundant field in a table
If it is found that there is a redundant field in the table, see the picture Redundant field in a database table, it must be removed. This can be done directly in the database administration in the tool intended for SQL server administration, for example SSMS for a Microsoft database. If it is a special table created in the Object designer, the "Deploy" operation must be performed in the given project, which ensures that the structure of the given table is aligned.

Picture: Redundant field in a database table
Consistency of field types in tables
Another part of the test is the consistency check of field types in tables, i.e. whether the expected data type of the field matches the existing one in the database. If a data type is incorrectly defined for a field in the table, this fact is displayed to the user, see Picture: Wrong data type of a field in a table. If it is a standard table, it is very likely that the field has an incorrect type because one of the conversions was not completed correctly during reinstallations to newer versions in the past. The procedure is therefore the same as for repairing missing fields in tables, see above.

Picture: Wrong data type of a field in a table
Other errors that the test can reveal, which are similar problems to those already described, including their repair, are Consistency of field ranges in tables, see Picture: Wrong field length in a table, and Existence of indexes and keys, see Picture: Missing index in a table.
Note
For a problem with a wrong field length, it is necessary to find the conversion script that handles the given conversion. If it cannot be found, it is necessary to contact the K2 technical department.

Picture: Wrong field length in a table

Picture: Missing index in a table
Note
The script for a missing index can be found in the same files as in the first point – Existence of tables. Running the script ("Create index") adds the index.
Existence of full-text indexes
The last phase of the check is a test for the existence of full-text indexes. There can be several variants of inconsistencies.
The first of them is a missing full-text index for a specific field, see Picture: Missing full-text index. In this case, full-text index support is enabled in K2 and at the same time a full-text index is defined in K2 for a field in a specific table. It was then found on the SQL server that no full-text index exists for this field.

Picture: Missing full-text index
We repair the indexes directly in K2 using the function Administrator - full-text key settings (function No. 778). After it is started, a form for the administration of full-text keys is displayed, where the necessary repair of the missing indexes can be made using the available buttons, see Picture: Full-text key administration.

Picture: Full-text key administration
The second possible inconsistency may, on the contrary, be a redundant index. For example, there may be a redundant index on a table for which K2 does not expect any index to exist, see Picture: Redundant full-text index.
Picture: Redundant full-text index
Or it may be redundant only for a specific table field, which means that an index is defined on the table in K2, but not for the listed field, see Picture: Missing full-text index for a field.

Picture: Missing full-text index for a field
In both cases, it is necessary to consider whether the index is desirable. If so, the structures must be aligned using the full-text index administration in K2. If it is not desirable, the field, the table or the entire full-text catalogue can be deleted directly from the SQL server database using the SSMS tool.
Note
If an index is redundant, it means that K2 will not use it. The SQL server has unnecessary overhead with the index, which reduces its performance, since it must maintain the index every time records are created or modified in the affected tables. It is therefore recommended to cancel the index, or to activate it in K2 if it is desirable for it to be used.
Check of the INIT and DEMO databases
The INIT and DEMO databases are also part of the check. These databases may also contain inconsistencies in their structures. In order not to slow down the reinstallation process unnecessarily by repairing databases that are distributed with K2, if the check reports an error in these databases, we do not have to solve the individual problems by gradual repairs, but simply have the databases restored.
To restore the INIT database, we run the function "Administrator / System / Client administration" from the menu in K2. We select the INIT database, switch to page number 2 and start the restoration with the "Database" button. After the query is confirmed, the database for INIT is deleted and recreated. No data are imported in this step. They are imported either by a subsequent reinstallation, or we can perform the import directly in the Client administration by pressing the "Data Import" button. Since we are in the process of reinstallation, it is not necessary to import the data.
Backup of all databases 2
After the database structures have been repaired, it is recommended to back up those that were affected. The step is defined in the point – Backup of all databases. We continue with the point Check of disk space (C, installation, databases).
Decision: The databases match the installed K2 version
Run: IS K2 administrator
Description: This is a decision step that we reach if an executable K2 is not available. See Decision: Is an executable K2 available?
If we have backups from a version that corresponds to the installed K2 version, or from which conversions to the installed version can be performed, and at the same time the k2.ini and sysk2.ini files with the correct values exist in the folder where we want to install, such a K2 remnant can be considered a version to which reinstallation is possible. We then continue with the step Decision: Do database backups exist?, otherwise we must perform the step Restoring databases from a backup.
Databases are restored in cases where errors occurred during the installation, especially in the SQL conversion part. Depending on the extent of the errors, these errors can either be repaired, or the databases can be restored and the problems solved in the previous version so that the subsequent conversion runs correctly. It is advisable to deal with any repairs together with the K2 technical department. Firstly, a repair may seem trivial, but further logic follows on from it, which may have run without an error message but worked with wrong data because of the previous error. Another reason is that the error did not manifest itself during testing, but only on the specific data of the customer.
Decision: Do database backups exist?
Run: IS K2 administrator
Description: In this decision step, we decide whether database backups need to be made and we can continue with the step Restoring databases from a backup, or backups need to be made and we then continue with the step Backup of all databases 2.
Restoring databases from a backup
Location: Database administration tool
Run: IS K2 administrator
Description: The step is performed using database administration tools that allow database backups to be made and that were mentioned in the step Backup of all databases.
Check of disk space (C, installation, databases)
Location: Windows OS
Run: IS K2 administrator
Permission: Administrator permission to administer the computer for the K2 installation and the database server
Condition: Optional operation. This is a manufacturer's recommendation. It is advisable to prevent situations where one of the affected disks runs out of space during the K2 installation.
Description: To avoid problems with insufficient disk space during the K2 reinstallation, it is recommended to check the amount of free space on all affected disks. This applies in particular to disk C on the computer where K2 is installed. Before the reinstallation, an MSI file is copied to this system disk as the installation medium. In addition, after the reinstallation is completed, this installation package is stored in the temporary directories of Windows OS until K2 is uninstalled.
If K2 is installed on a disk other than the system disk, it is advisable to check this location before the reinstallation as well.
The last location is the disks for the databases directly on the SQL server. During reinstallation, the databases are worked with, for example data are imported, structure conversions are performed, etc., so it is advisable to perform a check here as well.
Note
The size of the required space on the individual disks depends on the size of the installation medium and also on the size of the database. In some cases, a check for sufficient free space is performed, for example when the installation is started. There are situations when the check cannot be performed. It is therefore recommended to always check this information.
Starting the reinstallation
Location: K2 installer
Run: IS K2 administrator
Permission: Administrator permission to install applications on the given computer
Condition: The current version supports moving to the selected newer version.

Picture: Records with K2 installations
The reinstallation can run in two modes.
The first is a classic reinstallation, i.e. there is a complete working version of K2, which we have available in the K2 installer on the "Installed" tab, see Picture: Records with K2 installations. An update to the new version is started on this installation.
The second case is the so-called new installation by taking over an existing K2 installation. In this procedure, a new installation takes place, including the creation of a new record in the K2 installer after a successful installation. This update is very similar to the classic variant, with the difference that it is used in the following cases:
We only have a "remnant" of the current K2 installation
This means that we do not have the K2 binary files available; there are only data files, databases, configuration files, etc. The so-called "remnant" can arise, for example, after K2 has been uninstalled. Among other things, this state can occur in a situation where an uninstallation takes place as part of an update and an error occurs during the subsequent update after the uninstallation itself. In this case, K2 remains in a state where it cannot be started and only the data and configuration files remain on the disk.
There is no installation record in the K2 installer
Another reason is a missing installation record. In this case, we cannot start the update, because this option is not available. This can happen, for example, in a situation where the installation is migrated to another server, or we need to perform the reinstallation from a different computer than before.
Note
We use this installation in all cases where we do not have the binary files available or there is no installation record.
Note
If we update K2 in this way when the situation does not require it, the installation will be fine, but installation records will accumulate on the "Installed" tab in the K2 installer and installation files ("msi") used by the system for uninstallation will accumulate in Windows. If we then start an uninstallation on any duplicate record in the K2 installer, the files will be removed from the K2 directory, K2 will not be executable, and one installation file will be released from the operating system. The other records remain in the system as inconsistent data, including leftovers of installation files in Windows. Caution, each such file takes up approximately 1.7 GB of data. It is therefore recommended to perform K2 updates in the form of a classic update on an existing record on the "Installed" tab in the K2 installer.
After the installation status has been evaluated, it is necessary to decide which variant we will continue with. If a new installation by the so-called "takeover" is necessary, we continue with the point Decision: Is an executable K2 available? If we can perform the reinstallation by the standard procedure, we proceed with the point Starting the reinstallation.
Description
To update to a newer version, there must be a record with the current version in the K2 installer, on which the update is started.
The second condition is that the current version can be updated to the selected newer version. We verify this state by selecting the version to update to in the K2 installer. For an installation record, a version can be selected in the drop-down menu in the "Installation" column. If no version is available in the menu, it is probably not possible to update the current version to the newer one that is part of the K2 installer.
If no version is available for selection, it is possible to hover the mouse over the "?" symbol on the right-hand side of the installation record, and the K2 installer displays information about the current installation, including information on why no version was offered. Thanks to this, it is possible to find out via which version the user must perform the update in order to continue.
Note
The K2 installer works in two modes. In the first mode, the K2 installer is part of a zip archive with a specific K2 version downloaded from the K2 infoservice. In this case, only the option to update to the version for which the archive is intended is available. That is, there will be one version or none, depending on the condition, in the update menu.
In the second mode, the K2 installer works in such a way that it is installed on the computer used for installations; after starting, the user logs in to the K2 FTP server and has all currently released versions of K2 and other products available. In this case, the "Installation" drop-down menu will contain the version to which the update can be performed.
We start the K2 update by selecting the version and clicking the "Perform" button in the installation record of the K2 installer.
We continue the installation with the following step.
Decision: Does the original K2 exist?
Location: K2 installer
Run: K2 installer
Description: An executable K2 is located in the folder determined by the installer or selected during the installation. If so, the checks of mandatory version initializations and the database structure checks are performed automatically. The procedure and any repairs are described in the points Check of mandatory version initializations across all databases and check of structures of all databases.
Decision: Does a record exist in the installer?
Location: K2 installer
Run: K2 installer
Description: This decision is made internally in the installer and the user does not otherwise intervene in it. A record in the installer means that the installation was started from the Installed page, see Picture: Records with K2 installations. If such a record exists, we continue with the following step, otherwise we continue with Installation of the new version files.
Removal of the existing K2 installation
Location: K2 installer
Run: K2 installation wizard (MSI file)
Description: The first step performed by the installer when updating K2 the standard way is the removal of the existing installation. In this process, all files that were installed are removed. Files that were not added by the installation remain in the installation directory. If a file from the installation has been modified, i.e. it does not correspond to the file that was installed, it is also kept by the installer.
Decision: Removal OK?
An error may occur when removing the original installation. Likewise, an error may occur in the subsequent step, when the new installation is started. If this happens, we are in a state where we do not have a K2 installation, because it was removed, and thus we do not have a record to restart the update that ended with an error.
If the removal of the installation was successful and the new installation has started, we continue with the point Installation of the new version files.
If the removal failed, or the subsequent update failed and the existing installation was removed, we return to the beginning of the reinstallation and continue with the point Decision: Is an executable K2 available?, or we can end the installation process, but K2 will not be available at this point.
Installation of the new version files
Location: K2 installer
Run: K2 installation wizard (MSI file)
Description: The new installation is started after the previous installation has been successfully removed, or when we update K2 by taking over the existing installation. In this step, the new files that are part of the K2 installation start to be copied. After they have been successfully copied, an installation record is created in Windows OS.
After the files have been successfully copied, the process automatically continues with the next step, which the user cannot influence. This is the step SQL conversions.
SQL conversions
Location: K2 installer
Run: K2 installation wizard (MSI file)
Description: In this phase, the K2 installer runs files with conversion SQL scripts that convert the database structure for the new version. Depending on the type of update, a different number of files is run.
The following table summarizes the list of files that are run depending on the database platform and also on the scope of the update. In the case of an update to a new version, for example K2 mia › K2 luna, all these files are run. In smaller updates, only some of them are run.
File |
Platform |
Description |
New version |
New release |
New build |
K2_C2020.sql |
MS SQL |
CONF database |
X |
|
|
K2_C2020Ora.sql |
Oracle |
CONF database |
X |
|
|
K2_C2020Additional.sql |
MS SQL |
CONF database |
X |
X |
X |
K2_C2020OraAdditional.sql |
Oracle |
CONF database |
X |
X |
X |
K2_D2020.sql |
MS SQL |
company databases |
X |
|
|
K2_D2020Ora.sql |
Oracle |
company databases |
X |
|
|
K2_D2020Additional.sql |
MS SQL |
company databases |
X |
X |
X |
K2_D2020OraAdditional.sql |
Oracle |
company databases |
X |
X |
X |
The conversion files that are run for a new version contain a one-time, non-repeatable conversion. In these cases, large conversions take place, involving data transfers, etc. Such operations cannot be run repeatedly. This could damage the database structures or cause inconsistencies in the data.
The other conversion files are always run. Mostly these are operations such as adding a new field to a database table, a new table, etc. These files are prepared for repeated running without the risk of damaging the database or its consistency.
If an error occurs while the conversions are being run, each error is written to the output file "sql_inst.log", which is located directly in the K2 installation directory. In the event of an error, this file is displayed to the user at the end of the conversion.
Note
If an error occurs during the update after the conversion has run, and the entire update needs to be performed again, the databases must first be restored from the backup. This applies only to the state when conversions that cannot be run repeatedly have been run, see the table above. If the database backup was made only before the entire reinstallation and not after all the checks, it will be necessary to install or restore the original K2 file system from the backup so that all checks and preparations can be performed.
After the database conversions have been performed, the update continues with the point Mandatory initializations - part 1/2.
Mandatory initializations part 1/2
Location: K2 installer
Run: K2 installation wizard (MSI file)
Description: Within phase 1 of the mandatory initializations, only repairs of structures that could not be performed by running an SQL script are performed.
Decision: Did the original K2 exe exist?
Location: K2 installer
Run: K2 installation wizard (MSI file)
Description: If the k2.exe executable file was missing in the folder where the new K2 is being installed, and therefore the structure checks could not be performed before the reinstallation, these checks are performed now. If the checks have already been run on the original K2, we continue without these checks with the step Extensions update.
Extensions update

Picture Extensions update
Location: K2 installer
Run: K2 installation wizard (MSI file)
Description
After each K2 reinstallation, it is also necessary to update all extensions installed on K2. The update is performed automatically during the reinstallation.
As part of this action, the Object designer structures are aligned with the new K2 version. The update can take place in several steps and, depending on the number and dependencies of the extensions and the number of Clients, it can take a varying amount of time.
If an error occurs during the extensions update, it is dealt with only after the reinstallation process has finished. The reinstallation continues with the next steps.
Possible problems
If the update does not complete successfully during the reinstallation, a message about extensions that are not up to date is displayed when K2 is started to users who have the right to service operations, see Picture: Message - outdated extension in K2.

Picture: Message - outdated extension in K2
In this case, it is necessary to perform the update manually. K2 must be started with the special parameter EXTENSIONS=UPDATE RSOFF=1. At this moment, K2 starts updating all extensions that are outdated on the given K2. Depending on the extensions, a K2 restart may be required during the update. We recognize this by K2 terminating. At this moment, it is necessary to start the update again with the mentioned parameter. As soon as K2 remains running after the update, everything has been updated correctly and the message should no longer be displayed.
Note
The status of the extensions can be verified in the form under the "Extensions" function in the Object designer, where there is status information for each extension. This is the "Current" column, see Picture: Status of extensions on K2.

Picture: Status of extensions on K2
Note
An extension will work on K2 even if it is outdated. However, it is not advisable to leave K2 in this state. During the update operation, the structures are converted and new or cancelled properties are added, which are taken into account only after the update, so it is recommended to keep the compiled extension files in the same version as the K2 version.
Note
When moving to the K2 mia.03 version, it is necessary to convert the extension format from version 1.0 to version 2.01.
Conversion of the extension structure to the new format
In the K2 mia version (more precisely K2 mia.03), the file format for Object designer extensions was changed. This applies both to the definition xml file (extension) and to the files created for running K2 (extensions). The structures were upgraded to version 2.02. The information can be seen in Picture: Status of extensions on K2, in the "Format" column. If a reinstallation to this K2 version takes place, the extensions will continue to work, but only until some modification needs to be made. Before any modification, it is necessary to first perform a conversion to the new version 2.02.
The conversion is started in exactly the same way as the update, i.e. with the parameter EXTENSIONS=UPDATE RSOFF=1. Until this operation has been performed, it is not possible to modify extensions in the Object designer. After the conversion, the new structure is already in the "extensions" directory. For the extension definition, however, the old variant of the xml file remains. K2 does not know the location of the source for the "extensions" directory, so the definition cannot be converted automatically. Subsequently, if the user tries to open an outdated extension definition (after the conversion), K2 recognizes that a newer extension already exists in the "extensions" directory and automatically offers the user the transfer of the definition to the new structure in the location from which the definition is being opened. The transfer must be confirmed, otherwise the Object designer will not allow further work with this definition.

Picture: Information about an outdated extension definition
Note
The text mentions that K2 will work on the old structure until it needs to be modified. Of course, we do not recommend this mode. The administrator should perform the conversion to the new structure to ensure that the version of the extension sources is created on the same K2 version on which it is run.
Options of the EXTENSIONS parameter
The EXTENSIONS parameter takes several values that can be used. These are the following variants:
Parameter |
Description |
EXTENSIONS=OFF |
K2 starts without extensions. |
EXTENSIONS=UPDATE |
At start-up, all extensions installed in K2 that are outdated are updated. |
EXTENSIONS=UPDATE,ALL |
At start-up, all extensions installed in K2 are updated regardless of whether they are outdated or not. It is advisable to use this when transferring the "extensions" directory from another, test K2 that has the same version as the current K2. |
EXTENSIONS.EXT=name |
K2 uses the extension files from the "extensions.{name}" directory. The parameter is suitable for debugging purposes, when it is possible to start K2 with an extension that is available only with the given parameter. |
Data Import
Location: K2 installer
Run: K2 installation wizard (MSI file)
Description: New data for the system Clients DEMO and INIT are imported into K2. Furthermore, system records for various tables are imported into all Clients and, last but not least, the standard scripts are updated.
Mandatory initializations part 2/2
Location: K2 installer
Run: K2 installation wizard (MSI file)
Description: In this part of the installation, actions are performed that could not be performed within the conversions, or that require K2 logic, or for which a new script is needed.
Licence import
Location: K2 installer
Run: K2 installation wizard (MSI file)
Description: A new licence is imported into K2 from the file that was selected during the installation. This import takes place only for a version reinstallation or when taking over installations.
