#!/usr/bin/env bats load $BATS_TEST_DIRNAME/helper/common.bash setup() { setup_common dolt sql <" ]] || false dolt sql -q "insert into test (pk,c0,c1,c2,c3,c4,c5) values (0,0,0,0,0,0,0)" run dolt diff [ "$status" -eq 0 ] [[ "$output" =~ "| c0" ]] || false [[ "$output" =~ "+ | 0" ]] || false dolt sql -q "alter table test drop column c0" dolt diff } @test "schema-changes: dolt diff on schema changes rename primary key" { dolt add test dolt commit -m "committed table so we can see diffs" dolt sql -q "alter table test rename column pk to pk1" run dolt diff [ "$status" -eq 0 ] [[ "$output" =~ "pk1" ]] || false } @test "schema-changes: adding and dropping column should produce no diff" { dolt add test dolt commit -m "committed table so we can see diffs" dolt sql -q "alter table test add c0 bigint" dolt sql -q "alter table test drop column c0" run dolt diff [ "$status" -eq 0 ] [ "$output" = "" ] } @test "schema-changes: schema diff should show primary keys in output" { dolt add test dolt commit -m "committed table so we can see diffs" dolt sql -q 'alter table test rename column c2 to column2' run dolt diff --schema [ "$status" -eq 0 ] [[ "$output" =~ "PRIMARY KEY" ]] || false } @test "schema-changes: changing column does not allow nulls in primary key" { dolt sql < | 1 | 1 | NULL | | < | 2 | 2 | 2 | | > | 2 | 2 | NULL | +---+-----+-----+------+ EOF ) [[ "$output" =~ "$EXPECTED" ]] || false } # We passed nil where a sql ctx was expected in merge. When we added # collations, the sql ctx became required and merge started to panic. @test "schema-changes: regression test for merging check constraints with TEXT type panicking due to a nil sql ctx" { dolt sql -q "create table t (pk int primary key, col1 text);" dolt commit -Am "initial" dolt branch right dolt sql -q "insert into t values (1, 'valid');" dolt commit -am "row" dolt checkout right dolt sql -q "alter table t add constraint col1_check CHECK (col1 = 'valid');" dolt commit -am "add check" dolt checkout main dolt merge -m "merge" right run dolt sql -q "show create table t;" [ $status -eq 0 ] [[ $output =~ "CHECK ((\`col1\` = 'valid'))" ]] || false }