blob: d83387474271f8059b3def87a1fa12fa56e46917 [file] [log] [blame]
JvD_Ericsson0cf610f2024-07-24 16:34:11 +01001PG SQL Schema Generator
2#######################
3
4*PG SQL Schema Generator* provides the capability of generating a PostgreSQL schema from the YANG models. This schema
5in turn is used in TE&IV for validating, ingesting and exposing the topology.
6
7Algorithm
8*********
9
10Overview
11========
12
13The *PG SQL Schema Generator* necessitates the execution of multiple processes, each designed to fulfill distinct tasks
14ensuring the thorough completion of their designated tasks for the complete schema generation flow. The various stages
15involved in the schema generation are:
16
17- :ref:`Model information retrieval <Model Information Retrieval>`
18- :ref:`DB schema generation <PG SQL Schema Generation>`
19
20The logic behind each stage is explained below.
21
22Prerequisite
23============
24
25The main input for schema generation is the YANG modules. In order to start the process, we need to configure the path
26which contains all the YANG modules that should be considered for DB schema generation.
27
28The configuration is done in application.yaml as follows:
29
30.. code-block:: yaml
31
32 yang-model:
33 source: classpath:generate-defaults
34
35Model Information Retrieval
36===========================
37
38The models are used for identifying the entities & relationships information. For schema generation we need
39the following information:
40
41- modules
42- entities
43- relationships
44
45The logic for retrieving the above information is explained below.
46
47Modules
48-------
49
50Modules are identified with the help of the YANG parser.
51
52Refer YangParser.java "src/main/java/org/oran/smo/teiv/pgsqlgenerator/YangParser.java" for implementation.
53
54A module is constructed with the following details:
55
56- name: name of the module.
57- namespace: namespace of the module.
58- domain: domain of the module. Identified with the help of the statement 'domain' from the module 'o-ran-smo-teiv-common-yang-extensions'
59- revision: module revision.
60- content: content of the module.
JvD_Ericsson0cf610f2024-07-24 16:34:11 +010061- availableListElements: set to all the list elements defined in the module. Identified with the help of the statement with 'list' as the yang DOM element name.
62- availableEntities: Initially constructed as empty list. This will be populated later with all the entities defined in the module.
63- availableRelations: set to the list of all relationship names defined in the module. Identified with the help of the statement name 'or-teiv-yext:biDirectionalTopologyRelationship'
64- includedModules: set to the list of all the imported modules in the domain.
65
66Entity Types
67------------
68
69Entity types are identified from the yang.
70
71An entity type is constructed with the following details:
72
73- entityName: name of the entity.
JvD_Ericsson5d8bec52024-08-14 10:29:29 +010074- storedAt: where the entity information is stored i.e., table name. The table name is generated as
75 '<moduleName>_<entityName>'.
JvD_Ericsson0cf610f2024-07-24 16:34:11 +010076- moduleReferenceName: module to which the entity belongs. Identified by checking which of the identified modules has:
77
78 - the same namespace as the entity, and
79 - the availableListElements contains the entity name
80
81- consumerData: sourceIds, classifiers and decorators.
82- attributes: attributes for the entity. Retrieval of attribute information is detailed in the next section.
83
84Attributes
85^^^^^^^^^^
86
87For every identified entity, we also retrieve the attributes belonging to it. An attribute is constructed with the
88following information:
89
90- name: name of the attribute
91- dataType: dataType of the attribute. The datatype from the model is mapped to the corresponding DB datatype as shown in the below table:
92
93 +-----------------------+----------------+
94 | Model Attribute Types | Database Types |
95 +=======================+================+
96 | STRING | TEXT |
97 +-----------------------+----------------+
98 | COMPLEX_REF | jsonb |
99 +-----------------------+----------------+
100 | DOUBLE | DECIMAL |
101 +-----------------------+----------------+
102 | LONG | BIGINT |
103 +-----------------------+----------------+
104 | ENUM_REF | TEXT |
105 +-----------------------+----------------+
106 | MO_REF | TEXT |
107 +-----------------------+----------------+
108 | INTEGER | INTEGER |
109 +-----------------------+----------------+
110 | GEO_LOCATION | GEOGRAPHY |
111 +-----------------------+----------------+
112
113 **Note:** ID model attribute type is mapped to TEXT datatype as part of this algorithm.
114
115- constraints: list of constraints applicable for the attribute.
116- defaultValue: default value of the attribute.
117- indexTypes: indexes applicable for the attribute. Refer :ref:`Indexing Support <Indexing Support>` for more details on index.
118
119Relationship Types
120------------------
121
122Relationship types information is retrieved from the model. The model doesn't support retrieval of relationships
123directly, hence we get them by finding the outgoing associations for the identified entities.
124
125A relationship type is constructed with the following information:
126
127- name: name of the relationship
128- aSideAssociationName: name of the aSide association.
129- aSideMOType: aSide entity type.
130- aSideModule: module to which aSide entity type belongs.
131- aSideMinCardinality: minimum cardinality of the aSide.
132- aSideMaxCardinality: maximum cardinality of the aSide.
133- bSideAssociationName: name of the bSide association.
134- bSideMOType: bSide entity type.
135- bSideModule: module to which bSide entity type belongs.
136- bSideMinCardinality: minimum cardinality of the bSide.
137- bSideMaxCardinality: maximum cardinality of the bSide.
138- associationKind: association kind. eg, 'BI_DIRECTIONAL'.
139- connectSameEntity: whether the relationship connects the same entity type.
140- relationshipDataLocation: type of the table used for storing the relationship instances. Can be one of the following:
141
142 - A_SIDE
143 - B_SIDE
144 - RELATION
145
JvD_Ericsson5d8bec52024-08-14 10:29:29 +0100146- storedAt: table name where the relationship instances is stored. The logic for determining the table name relies on the cardinality of the relationship.
147
JvD_Ericsson0cf610f2024-07-24 16:34:11 +0100148 +--------------------------------------------------+----------------------------+
149 | Case | Relationship instance info |
150 +==================================================+============================+
151 | 1:1 | aSide |
152 +--------------------------------------------------+----------------------------+
153 | 1:N / N:1 | N-side |
154 +--------------------------------------------------+----------------------------+
155 | N:M | relation table |
156 +--------------------------------------------------+----------------------------+
157 | Relations connecting same Entity Types | relation table |
158 | 1 : 1 (or) 1 : n (or) m : n | |
159 +--------------------------------------------------+----------------------------+
160
161- moduleReferenceName: module to which the relationship belongs. The relationship module is identified by identifying the module that contains the relationship name in the availableRelations list.
162- consumerData: sourceIds, classifiers, decorators.
JvD_Ericsson5d8bec52024-08-14 10:29:29 +0100163- aSideStoredAt: table name where aSide entity type instances are stored.
164- bSideStoredAt: table name where bSide entity type instances are stored.
JvD_Ericsson0cf610f2024-07-24 16:34:11 +0100165
166Indexing Support
167----------------
168
JvD_Ericsson0cf610f2024-07-24 16:34:11 +0100169Indexing is supported for the identified column's based on the column's data type.
170
171Currently, we support indexing on JSONB columns.
172
173- GIN Index: used for columns storing object, eg, decorators.
174- GIN TRIGRAM Index: used for columns storing list of entries, eg, classifiers, sourceIds.
175
JvD_Ericsson5d8bec52024-08-14 10:29:29 +0100176Refer IndexType.java "src/main/java/org/oran/smo/teiv/pgsqlgenerator/schema/IndexType.java" for types of index supported.
177
JvD_Ericsson0cf610f2024-07-24 16:34:11 +0100178PG SQL Schema Generation
179========================
180
181Data schema
182-----------
183
184The information gathered from the model is then used to generate the TE&IV data schema
185by creating tables from entities and relationships which is needed for persisting data,
186this is performed in numerous steps.
187
188Firstly, the data schema is prepared for use this is done by checking if a baseline data schema
189file already exists. If it does not exist or if it's a green field installation,
190it copies a skeleton data schema file to the new data schema file location.
191Otherwise, if the baseline data schema file exists, it copies it to the new data schema file location.
192
193Once the data schema is prepared the entities and relationships retrieved from the model need to be converted
194into structured tables suitable for database storage. It starts by analyzing the relationships
195between entities to determine the appropriate tables for storing relationship data,
196considering various connection types such as one-to-one, one-to-many, many-to-one and many-to-many.
197
198Next, it iterates over the entities generating the tables and columns based on their attributes.
199For each entity, it creates a table with columns representing its attributes and columns to accommodate
200associated relationships, ensuring adequate capturing of the relationships between entities.
201In the case where there is many-to-many relationships or relationships between same entity type
202these relationships are granted their own tables.
203
204For every entity and relationship identified from the model, we add additional columns to store **sourceIds**,
205**classifiers** and **decorators** information. This hard coding is necessary as sourceIds, classifiers and decorators
206are not transformed as part of the yang model as it is for now considered consumer data.
207
208+-----------------------------------------+-------+---------------+-------------------------------------------------------------------------------------------+
209| Column name | Type | Default | Description |
210| | | | |
211| | | Value | |
212+=========================================+=======+===============+===========================================================================================+
213| CD_sourceIds | jsonb | [] | Stores sourceIds for entities in entities table and relationships in relationship tables. |
214+-----------------------------------------+-------+---------------+-------------------------------------------------------------------------------------------+
215| REL_CD_sourceIds_<RELATIONSHIP_NAME> | jsonb | [] | Stores sourceIds for relationship inside an entity table. |
216+-----------------------------------------+-------+---------------+-------------------------------------------------------------------------------------------+
217| CD_classifiers | jsonb | [] | Stores classifiers for entities in entities table. |
218+-----------------------------------------+-------+---------------+-------------------------------------------------------------------------------------------+
219| REL_CD_classifiers_<RELATIONSHIP_NAME> | jsonb | [] | Stores classifiers for relationship inside an entity table. |
220+-----------------------------------------+-------+---------------+-------------------------------------------------------------------------------------------+
221| CD_decorators | jsonb | {} | Stores decorator for entities in entities table. |
222+-----------------------------------------+-------+---------------+-------------------------------------------------------------------------------------------+
223| REL_CD_decorators_<RELATIONSHIP_NAME> | jsonb | {} | Stores decorator for relationship inside an entity table. |
224+-----------------------------------------+-------+---------------+-------------------------------------------------------------------------------------------+
225
226When it comes to data integrity, constraints are applied to the columns. These constraints include the following:
227
228- **Primary keys:** Used to uniquely identify each record.
229- **Foreign keys:** Used for establishing relationships between tables.
230- **Uniqueness:** Used to ensure data population and prevent duplicated data.
231
232After this, tables are retrieved from the baseline schema by extracting and parsing the data. This is done by identifying various statements such as table creation, column definitions, constraints, indexes and default values from the retrieved schema file. From this it generates a comprehensive list of tables along with their respective columns and constraints.
233
234A comparison then happens between the tables from the baseline schema and the model service by performing the following actions:
235
236- Identify differences between the tables
237- Check table / column consistency
238- Verify default values and label any discrepancies
239- Verify any changes in the index
240
241The differences from this operation are then used for schema generation by generating PG SQL statements to modify/create database schema based on the identified differences between the models. It first analyzes the differences and then generates appropriate SQL statements for alterations or creations of tables and columns.
242
243These statements cater for the following scenarios:
244
245- Adding new tables / columns
246- Constraint definition such as UNIQUE or NOT NULL
247- Default value handling
248- Existing attributes modification
249- Index definition
250
251Finally, the generated schema is written into the prepared SQL file.
252
253Model Schema
254------------
255
256Following this procedure, it then proceeds to produce the TE&IV model schema by crafting SQL entries for diverse tables associated with the model, which in turn is used for dynamically loading data in schema service at start up for modules, entities and relationships.
257
258These SQL entries include:
259
260**execution_status:** This table helps in storing the execution status of the schema. This will be used in the kubernetes init containers to confirm the successful execution of the schema.
261
262+---------------+--------------------------+--------------------------------+
263| Column name | Type | Description |
264+===============+==========================+================================+
265| schema | VARCHAR(127) PRIMARY KEY | Name of the schema |
266+---------------+--------------------------+--------------------------------+
267| status | VARCHAR(127) | Status of the schema execution |
268+---------------+--------------------------+--------------------------------+
269
270**hash_info:** Postgres sets a limit of 63 characters for names of the columns, tables and constraints. Characters after the 63rd character are truncated. Names that are longer than 63 characters are hashed using SHA-1 hashing algorithm and used. _hash_info_ tables holds the name, hashedValue and the type of the entry.
271
272Sample entries:
273
274- **Hashed**: UNIQUE_GNBCUUPFunction_REL_ID_MANAGEDELEMENT_MANAGES_GNBCUUPFUNCTION, UNIQUE_BDB349CDF0C4055902881ECCB71F460AE1DD323E, CONSTRAINT
275- **Un-hashed**: NRSectorCarrier, NRSectorCarrier, TABLE
276
277+---------------+--------------------------+-----------------------------------------------------------+
278| Column name | Type | Description |
279+===============+==========================+===========================================================+
280| name | TEXT PRIMARY KEY | Table / column / constraint name |
281+---------------+--------------------------+-----------------------------------------------------------+
282| hashedValue | VARCHAR(63) NOT NULL | | Hashed version of name column value if over 63 |
283| | | | character otherwise same un-hashed value |
284+---------------+--------------------------+-----------------------------------------------------------+
285| type | VARCHAR(511) | | The type of information associated i.e. Table, column |
286| | | | or constraint |
287+---------------+--------------------------+-----------------------------------------------------------+
288
289**module_reference:** For the module reference related module names from provided entities retrieved from the model service are extracted and stored which will be used for execution to module_reference table.
290
291+-----------------+-----------------------+------------------------------------------------+
292| Column name | Type | Description |
293+=================+=======================+================================================+
294| name | TEXT PRIMARY KEY | The module name |
295+-----------------+-----------------------+------------------------------------------------+
296| namespace | TEXT | The namespace the module is located |
297+-----------------+-----------------------+------------------------------------------------+
298| domain | TEXT | The domain the module is a part of |
299+-----------------+-----------------------+------------------------------------------------+
300| includedModules | jsonb | | aSideMO's and bSideMO's module reference |
301| | | | name stored within the Module |
302+-----------------+-----------------------+------------------------------------------------+
303| revision | TEXT NOT NULL | The revision date of the file |
304+-----------------+-----------------------+------------------------------------------------+
305| content | TEXT NOT NULL | | The base64 encoded format of the |
306| | | | corresponding schema. |
307+-----------------+-----------------------+------------------------------------------------+
308| ownerAppId | VARCHAR(511) NOT NULL | The identity of the owner App. |
309+-----------------+-----------------------+------------------------------------------------+
310| status | VARCHAR(127) NOT NULL | | Current status of the module reference to |
311| | | | track during the pod's life cycle. Needed |
312| | | | to avoid data loss / corruption. |
313+-----------------+-----------------------+------------------------------------------------+
314
JvD_Ericsson0cf610f2024-07-24 16:34:11 +0100315**entity_info:** For the entity info generation SQL entries are created and stored which will be used for execution to populate entity_info table.
316
317+------------------------------------------+------------------+-----------------------------------------+
318| Column name | Type | Description |
319+==========================================+==================+=========================================+
320| name | TEXT NOT NULL | The entity type name |
321+------------------------------------------+------------------+-----------------------------------------+
322| moduleReferenceName | TEXT NOT NULL | A reference to an associated module |
323+------------------------------------------+------------------+-----------------------------------------+
324| | FOREIGN KEY ("moduleReferenceName") | FOREIGN KEY | Foreign key constraint |
325| | REFERENCES ties_model.module_reference | | |
326| | ("name") ON DELETE CASCADE | | |
327+------------------------------------------+------------------+-----------------------------------------+
328
329**relationship_info:** When it comes to relationship info generation module reference names are assigned to relationships. For each relationship the max cardinality is taken and then sorted depending on the connection type:
330
331+------------------------------------------+------------------+-------------------------------------------------------------------+
332| Column name | Type | Description |
333+==========================================+==================+===================================================================+
334| name | TEXT PRIMARY KEY | The name of the relationship |
335+------------------------------------------+------------------+-------------------------------------------------------------------+
336| aSideAssociationName | TEXT NOT NULL | The association name for the A-side of the relationship |
337+------------------------------------------+------------------+-------------------------------------------------------------------+
338| aSideMOType | TEXT NOT NULL | The type of the managed object on the A-side of the relationship |
339+------------------------------------------+------------------+-------------------------------------------------------------------+
340| aSideModule | TEXT NOT NULL | The aSide module name |
341+------------------------------------------+------------------+-------------------------------------------------------------------+
342| aSideMinCardinality | BIGINT NOT NULL | The minimum cardinality of the A-side of the relationship |
343+------------------------------------------+------------------+-------------------------------------------------------------------+
344| aSideMaxCardinality | BIGINT NOT NULL | The maximum cardinality of the A-side of the relationship |
345+------------------------------------------+------------------+-------------------------------------------------------------------+
346| bSideAssociationName | TEXT NOT NULL | The association name for the B-side of the relationship |
347+------------------------------------------+------------------+-------------------------------------------------------------------+
348| bSideMOType | TEXT NOT NULL | The type of the managed object on the B-side of the relationship |
349+------------------------------------------+------------------+-------------------------------------------------------------------+
350| bSideModule | TEXT NOT NULL | The bSide module name |
351+------------------------------------------+------------------+-------------------------------------------------------------------+
352| bSideMinCardinality | BIGINT NOT NULL | The minimum cardinality of the B-side of the relationship |
353+------------------------------------------+------------------+-------------------------------------------------------------------+
354| bSideMaxCardinality | BIGINT NOT NULL | The maximum cardinality of the B-side of the relationship |
355+------------------------------------------+------------------+-------------------------------------------------------------------+
356| associationKind | TEXT NOT NULL | The kind of association between entities |
357+------------------------------------------+------------------+-------------------------------------------------------------------+
358| relationshipDataLocation | TEXT NOT NULL | Indicates where associated relationship data is stored |
359+------------------------------------------+------------------+-------------------------------------------------------------------+
360| connectSameEntity | BOOLEAN NOT NULL | Indicates whether the relationship connects the same entity |
361+------------------------------------------+------------------+-------------------------------------------------------------------+
362| moduleReferenceName | TEXT PRIMARY KEY | The name of the module reference associated with the relationship |
363+------------------------------------------+------------------+-------------------------------------------------------------------+
364| | FOREIGN KEY ("aSideModule") REFERENCES | FOREIGN KEY | Foreign key constraint |
365| | ties_model.module_reference ("name") | | |
366| | ON DELETE CASCADE | | |
367+------------------------------------------+------------------+-------------------------------------------------------------------+
368| | FOREIGN KEY ("bSideModule") REFERENCES | FOREIGN KEY | Foreign key constraint |
369| | ties_model.module_reference ("name") | | |
370| | ON DELETE CASCADE | | | |
371+------------------------------------------+------------------+-------------------------------------------------------------------+
372| | FOREIGN KEY ("moduleReferenceName") |FOREIGN KEY | Foreign key constraint |
373| | REFERENCES | | |
374| | ties_model.module_reference ("name") | | |
375| | ON DELETE CASCADE | | |
376+------------------------------------------+------------------+-------------------------------------------------------------------+
377
378Along with this, it ensures that the structure for the model schema SQL file starts with the correct structure by importing the baseline schema information.
379
380Finally, these generated entries and structure are then used to modify the model SQL file.
381
JvD_Ericsson5d8bec52024-08-14 10:29:29 +0100382Consumer Data Schema
383^^^^^^^^^^^^^^^^^^^^
384
385Before classifying entities or relationships, a schema must be created and validated.
386It can be created, by using its own endpoint, with a Yang Module.
387The user must provide a unique module name, to avoid collision of multiple users access that are defining classifiers and decorators.
388The schema cannot be modified later on but only deleted and recreated, if needed.
389When a schema is successfully created and validated, the user can add the classifiers to the entities or relationships.
390
391Classifiers
392"""""""""""
393
394Classifiers support the following two types of 'operation', which must be identified in the body of the request:
395- merge: defined classifiers can be applied to entities and relationships within a single request.
396- delete: existing tagged classifiers can be removed.
397
398**Example:**
399In this example, user is classifying two given entity IDs and a single relationship ID with a single request.
400
401.. code-block:: json
402
403 {
404 "operation": "merge",
405 "classifiers": [
406 "module-x:Outdoor",
407 "module-y:Rural",
408 "module-z:Weekend"
409 ],
410 "entityIds": [
411 "urn:3gpp:dn:ManagedElement=1,GNBDUFunction=1,NRCellDU=1",
412 "urn:3gpp:dn:ManagedElement=1,GNBDUFunction=1,NRCellDU=2"
413 ],
414 "relationshipIds": [
415 "urn:o-ran:smo:teiv:sha512:NRCELLDU_USES_NRSECTORCARRIER=CA576F4716C36A1BD1C506DCB58418FC731858D3D3F856F536813A8C4D3F1CC21292E506815410E04496D709D96066EBC0E4890DEFC3789EDC4BD9C28DA1D52B"
416 ]
417 }
418
419Decorators
420""""""""""
421
422Decorators support the following two types of 'operations', which must be identified in the body of the request:
423- merge: existing decorators can be updated or applied to entities and relationships within a single request.
424- delete: existing tagged decorators can be removed.
425
426**Example:**
427In this example, user is tagging decorators with two given entity IDs and a single relationship ID with a single request.
428
429.. code-block:: json
430
431 {
432 "operation": "merge",
433 "decorators": {
434 "module-x:location": "Stockholm",
435 "module-y:vendor": "Ericsson"
436 },
437 "entityIds": [
438 "urn:3gpp:dn:ManagedElement=1,GNBDUFunction=1,NRCellDU=1",
439 "urn:3gpp:dn:ManagedElement=1,GNBDUFunction=1,NRCellDU=2"
440 ],
441 "relationshipIds": [
442 "urn:o-ran:smo:teiv:sha512:NRCELLDU_USES_NRSECTORCARRIER=CA576F4716C36A1BD1C506DCB58418FC731858D3D3F856F536813A8C4D3F1CC21292E506815410E04496D709D96066EBC0E4890DEFC3789EDC4BD9C28DA1D52B"
443 ]
444 }
445
446The SQL entries for consumer data include
447- **module_reference:** For the consumer module reference related module names from provided classifiers or decorators retrieved from the model service are extracted and stored which will be used for execution to module_reference table.
448
449+-------------+-----------------------+-----------------------------------------------------------------+
450| Column name | Type | Description |
451+=============+=======================+=================================================================+
452| name | TEXT PRIMARY KEY | The module name |
453+-------------+-----------------------+-----------------------------------------------------------------+
454| namespace | TEXT | The namespace the module is located |
455+-------------+-----------------------+-----------------------------------------------------------------+
456| revision | TEXT NOT NULL | The revision date of the file |
457+-------------+-----------------------+-----------------------------------------------------------------+
458| content | TEXT NOT NULL | The base64 encoded format of the corresponding schema. |
459+-------------+-----------------------+-----------------------------------------------------------------+
460| ownerAppId | VARCHAR(511) NOT NULL | The identity of the owner App. |
461+-------------+-----------------------+-----------------------------------------------------------------+
462| status | VARCHAR(127) NOT NULL | | Current status of the consumer module reference to track |
463| | | | during the pod's life cycle. Needed to avoid data |
464| | | | loss / corruption. |
465+-------------+-----------------------+-----------------------------------------------------------------+
466
467**decorators:** There will be the ability for Administrators to decorate topology entities and relationships. We will be storing the schemas for the decorators in this table.
468
469+--------------------------------------------------+------------------+-----------------------------------+
470| Column name | Type | Description |
471+==================================================+==================+===================================+
472| name | TEXT PRIMARY KEY | The key of the decorator. |
473+--------------------------------------------------+------------------+-----------------------------------+
474| dataType | VARCHAR(511) | | The data type of the decorator, |
475| | | | needed for parsing. |
476+--------------------------------------------------+------------------+-----------------------------------+
477| moduleReferenceName | TEXT | | References the corresponding |
478| | | | module reference the decorator |
479| | | | belongs to. |
480+--------------------------------------------------+------------------+-----------------------------------+
481| | FOREIGN KEY ("moduleReferenceName") REFERENCES | FOREIGN KEY | Foreign key constraint |
482| | ties_consumer_data.module_reference ("name") | | |
483| | ON DELETE CASCADE | | |
484+--------------------------------------------------+------------------+-----------------------------------+
485
486**classifier:** There will be the ability for client applications to apply user-defined keywords/tags (classifiers) to topology entities and relationships. We will be storing the schemas for the classifiers in this table.
487
488+--------------------------------------------------+------------------+-----------------------------------+
489| Column name | Type | Description |
490+==================================================+==================+===================================+
491| name | TEXT PRIMARY KEY | The key of the classifier. |
492+--------------------------------------------------+------------------+-----------------------------------+
493| moduleReferenceName | TEXT | | References the corresponding |
494| | | | module reference the classifier |
495| | | | belongs to. |
496+--------------------------------------------------+------------------+-----------------------------------+
497| | FOREIGN KEY ("moduleReferenceName") REFERENCES | FOREIGN KEY | Foreign key constraint |
498| | ties_consumer_data.module_reference ("name") | | |
499| | ON DELETE CASCADE | | |
500+--------------------------------------------------+------------------+-----------------------------------+
501
502How to use classifiers and decorators
503"""""""""""""""""""""""""""""""""""""
504
5051. Create a schema with the /schemas endpoint using Yang Module. After a successful schema creation, the topology objects are ready to be classified.
5062. Assign classifiers and/or decorators to the entities and/or relationships.
5073. Search classifiers and/or decorators by using queries.
508
JvD_Ericsson0cf610f2024-07-24 16:34:11 +0100509Skeleton Data and Model SQL Files
510=================================
511
512- 00_init-oran-smo-teiv-data.sql "src/main/resources/scripts/00_init-oran-smo-teiv-data.sql"
513
514 Proprietary PG SQL Function
515
516 Create constant if it doesn't exist
517
518 .. code-block:: sql
519
520 CREATE OR REPLACE FUNCTION ties_data.create_constraint_if_not_exists (
521 t_name TEXT, c_name TEXT, constraint_sql TEXT
522 )
523 RETURNS void AS
524 BEGIN
525 IF NOT EXISTS (SELECT constraint_name FROM information_schema.table_constraints
526 WHERE table_name = t_name AND constraint_name = c_name) THEN
527 EXECUTE constraint_sql;
528 END IF;
529 END;
530
531 Example:
532
533 .. code-block:: sql
534
535 SELECT ties_data.create_constraint_if_not_exists(
536 'CloudNativeApplication',
537 'PK_CloudNativeApplication_id',
538 'ALTER TABLE ties_data."CloudNativeApplication" ADD CONSTRAINT "PK_CloudNativeApplication_id" PRIMARY KEY ("id");'
539 );
540
541- "01_init-oran-smo-teiv-model.sql "src/main/resources/scripts/01_init-oran-smo-teiv-model.sql"
542
543Unsupported Non-Backward Compatible(NBC) Model Changes
544======================================================
545
546The following NBC model changes are unsupported due to their actions resulting in issues for upgrade scenarios.
547
548+-------------------------------------------------------+
549| Change |
550+=======================================================+
551| Delete attributes / entities / relationships |
552+-------------------------------------------------------+
553| Modify constraints on the attributes / relationships |
554+-------------------------------------------------------+
555| Change datatype of the attributes |
556+-------------------------------------------------------+
557| Rename attributes / relationships / entities |
558+-------------------------------------------------------+
559| Change aSide / bSide associated with a relationship |
560+-------------------------------------------------------+
561| Change cardinality of aSide / bSide in a relationship |
562+-------------------------------------------------------+
563
564There are checks in place to identify any NBC model change from above. These checks will compare the extracted data from baseline schema with data from model service to identify NBC model changes.
565
566NBC checks:
567
568- Verify deletion or modification to any attribute / entities / relationships and their properties.
569- Validate constraints on attributes / relationships.
570- Identify change to aSide / bSide managed object associated with a relationship.
571- Verify cardinality constraints to aSide/bSide of a relationship.
572
573If there is a requirement to update schema with NBC changes, in such case green field installation must be turned on. Green field installation enables the PG SQL Schema generator service to construct a new schema from scratch rather than updating on top of existing baseline schema.
574
575Please refer to BackwardCompatibilityChecker.java "src/main/java/org/oran/smo/teiv/pgsqlgenerator/schema/BackwardCompatibilityChecker.java" for more info.
576
577Local Use
578=========
579
580Copy YANG models into the generate-defaults "src/main/resources/generate-defaults" directory. Once done, perform the schema generation process by running the Spring Boot application within the pgsql-schema-generator directory using *mvn spring-boot:run*. The command will also run the Spring Boot tests and output the results.
581
582To run the test suite:
583
584- In your terminal, navigate into the pgsql-schema-generator directory and run 'mvn clean install'
585- In your terminal, navigate into the pgsql-schema-generator directory and run 'mvn -Dtest=<Test Name> test'