Creating custom UNIQUE constraints on a table

If we have a table with FirstName and LastName and we would like the combination of FirstName and LastName to be UNIQUE, in MySql this would be accomplished with a two-column UNIQUE constraint at the end of a table definition. Is there any way to access the underlying MySQL database on AWS Aurora to create this custom constraint? ie a way to apply a custom migration? Thanks!

Hey @mikesol

You won’t be able to access the underlying MySQL database. However, you can create a stored calculated field with a unique constraint that will accomplish this exact scenario.

Here’s a screen shot I just tested for it.

The SQL function is CONCAT() and then you can use the API field names on the record - same names as are used on the graphql api.

CONCAT(firstName, " ", lastName)

This only works for the records attributes, and you cannot access related records, like:

CONCAT(firstName, " loves ", favoriteFood.name)