Open kewinbrand opened 7 months ago
Hi, the last command should work in this form (computing actual index name, see details in wiki):
IF NOT EXISTS (SELECT TOP 1 1 FROM SYS.INDEXES WHERE NAME = sys.babelfish_truncate_identifier(lower('IX_ESTOQUE_EMPRESA_CODIGO' + 'ESTOQUE_EMPRESA') + md5(lower('IX_ESTOQUE_EMPRESA_CODIGO'))))
BEGIN
CREATE NONCLUSTERED INDEX [IX_ESTOQUE_EMPRESA_CODIGO] ON ESTOQUE_EMPRESA ([CODIGO])
END
GO
Minor correction, to get correct mangled index or constraint name it is necessary to apply babelfish_truncate_identifier
to index and table names before concatenation:
select sys.babelfish_truncate_identifier(
sys.babelfish_truncate_identifier(lower('idx_or_constraint_name')) +
sys.babelfish_truncate_identifier(lower('table_name')) +
md5(sys.babelfish_truncate_identifier(lower('idx_or_constraint_name'))))
This is also affecting my application (we are using BABEL_4_X_DEV).
While the workaround provided by @staticlibs works, it's not ideal for my case, as the migration scripts need to be shared between a Babelfish instance and a SQL Server one.
A fix is planned for this issue or this workaround is the way for now?
What happened?
we use the SYS.INDEXES table during our update process, but it seems that babelfish is not converting the names correctly. see example
Script
fails with Msg 2714, Level 16, State 1, Line 27 relation "ix_estoque_empresa_codigoestoquab8ae8734a5c39898c705577384d1f72" already exists
it is also worth to mention that we are using BABEL_4_X_DEV branch
Version
BABEL_3_X_DEV (Default)
Extension
babelfishpg_tsql (Default)
Which flavor of Linux are you using when you see the bug?
Ubuntu (Default)
Relevant log output
No response
Code of Conduct