feedzai/pdb

Standardize the behavior of entity creation

Opened this issue · 0 comments

When we create a new entity, we can define a column to have a UNIQUE constraint and also to have an explicit Index in Postgres. However, if we use oracle, the code will crash. We can either have a UNIQUE constraint on the column or an explicit Index as Oracle and most of the relational databases automatically create an index for columns with UNIQUE constraints. As PDB is supposed to have the same behavior with all DBs, when we have an Index and UNIQUE constraint defined for the same column, we should fail fast or handle this situation by ensuring that when a UNIQUE constraint is created, then one and only one Index is present for that column.

Another problem that may happen with entity creation is when we have a foreign key (FK) referencing another table and the FK column is a STRING without size defined. This will be a problem in SQL Server. A possible solution here may be to check the column size of the referenced column and add the same size to the FK column. This must be done for all DB Engines.