beam
                                
                                 beam copied to clipboard
                                
                                    beam copied to clipboard
                            
                            
                            
                        Composite column constraints
Is there any way to add constraints to column composites? For example, I'd like to impose a uniqueness constraint to a pair of columns directly in Beam. Should I just delegate this to raw SQL commands?
CREATE TABLE someTable  (
    id serial PRIMARY KEY,
    col1 int NOT NULL,
    col2 int NOT NULL,
    UNIQUE (col1, col2)
)
I can get around it for now by making it a composite primary key, but I really don't want to do that.
Thanks
Beam exists at a higher level than most constraint systems. Beam-core is ultimately a system for managing the queries issued to a database. The constraints the database follows are a secondary interest item. The primary key system exists mainly as a convenience.
You should use proper SQL change management tooling to manage your DDLs. Beam-migrate has some support for this, but is not totally complete. Beam-migrate does not support arbitrary constraints yet.
Beam will respect UNIQUE constraints in the sense that attempting to insert duplicates into a table with UNIQUE constraints will result in a DB exception, which beam should correctly propagate.
Does that make sense?