@@ -345,6 +345,181 @@ var testTableGetChangeTestCases = []testTableGetChangeTestCase{
345345 },
346346 },
347347 },
348+
349+ {
350+ name : "move to cq_id as primary key" ,
351+ target : & Table {
352+ Name : "test" ,
353+ Columns : []Column {
354+ {
355+ Name : "_cq_id" ,
356+ Type : types .ExtensionTypes .UUID ,
357+ Description : "Internal CQ ID of the row" ,
358+ NotNull : true ,
359+ Unique : true ,
360+ PrimaryKey : true ,
361+ },
362+ {Name : "bool" , Type : arrow .FixedWidthTypes .Boolean , PrimaryKey : false },
363+ },
364+ },
365+ source : & Table {
366+ Name : "test" ,
367+ Columns : []Column {
368+ {
369+ Name : "_cq_id" ,
370+ Type : types .ExtensionTypes .UUID ,
371+ Description : "Internal CQ ID of the row" ,
372+ NotNull : true ,
373+ Unique : true ,
374+ },
375+ {Name : "bool" , Type : arrow .FixedWidthTypes .Boolean , PrimaryKey : true },
376+ },
377+ },
378+ expectedChanges : []TableColumnChange {
379+ {
380+ Type : TableColumnChangeTypeMoveToCQOnly ,
381+ },
382+ {
383+ Type : TableColumnChangeTypeUpdate ,
384+ ColumnName : "_cq_id" ,
385+ Current : Column {
386+ Name : "_cq_id" ,
387+ Type : types .ExtensionTypes .UUID ,
388+ Description : "Internal CQ ID of the row" ,
389+ NotNull : true ,
390+ Unique : true ,
391+ PrimaryKey : true ,
392+ },
393+ Previous : Column {
394+ Name : "_cq_id" ,
395+ Type : types .ExtensionTypes .UUID ,
396+ Description : "Internal CQ ID of the row" ,
397+ NotNull : true ,
398+ Unique : true ,
399+ },
400+ },
401+ {
402+ Type : TableColumnChangeTypeUpdate ,
403+ ColumnName : "bool" ,
404+ Current : Column {Name : "bool" , Type : arrow .FixedWidthTypes .Boolean , PrimaryKey : false },
405+ Previous : Column {Name : "bool" , Type : arrow .FixedWidthTypes .Boolean , PrimaryKey : true },
406+ },
407+ },
408+ },
409+
410+ {
411+ name : "move to cq_id as primary key and drop unique constraint" ,
412+ target : & Table {
413+ Name : "test" ,
414+ Columns : []Column {
415+ {
416+ Name : "_cq_id" ,
417+ Type : types .ExtensionTypes .UUID ,
418+ Description : "Internal CQ ID of the row" ,
419+ NotNull : true ,
420+ // Unique: true,
421+ PrimaryKey : true ,
422+ },
423+ {Name : "bool" , Type : arrow .FixedWidthTypes .Boolean , PrimaryKey : false },
424+ },
425+ },
426+ source : & Table {
427+ Name : "test" ,
428+ Columns : []Column {
429+ {
430+ Name : "_cq_id" ,
431+ Type : types .ExtensionTypes .UUID ,
432+ Description : "Internal CQ ID of the row" ,
433+ NotNull : true ,
434+ Unique : true ,
435+ },
436+ {Name : "bool" , Type : arrow .FixedWidthTypes .Boolean , PrimaryKey : true },
437+ },
438+ },
439+ expectedChanges : []TableColumnChange {
440+ {
441+ Type : TableColumnChangeTypeMoveToCQOnly ,
442+ },
443+ {
444+ Type : TableColumnChangeTypeUpdate ,
445+ ColumnName : "_cq_id" ,
446+ Current : Column {
447+ Name : "_cq_id" ,
448+ Type : types .ExtensionTypes .UUID ,
449+ Description : "Internal CQ ID of the row" ,
450+ NotNull : true ,
451+ Unique : false ,
452+ PrimaryKey : true ,
453+ },
454+ Previous : Column {
455+ Name : "_cq_id" ,
456+ Type : types .ExtensionTypes .UUID ,
457+ Description : "Internal CQ ID of the row" ,
458+ NotNull : true ,
459+ Unique : true ,
460+ },
461+ },
462+ {
463+ Type : TableColumnChangeTypeRemoveUniqueConstraint ,
464+ ColumnName : "_cq_id" ,
465+ Previous : Column {
466+ Name : "_cq_id" ,
467+ Type : types .ExtensionTypes .UUID ,
468+ Description : "Internal CQ ID of the row" ,
469+ NotNull : true ,
470+ Unique : true ,
471+ },
472+ },
473+ {
474+ Type : TableColumnChangeTypeUpdate ,
475+ ColumnName : "bool" ,
476+ Current : Column {Name : "bool" , Type : arrow .FixedWidthTypes .Boolean , PrimaryKey : false },
477+ Previous : Column {Name : "bool" , Type : arrow .FixedWidthTypes .Boolean , PrimaryKey : true },
478+ },
479+ },
480+ },
481+
482+ {
483+ name : "drop unique constraint" ,
484+ target : & Table {
485+ Name : "test" ,
486+ Columns : []Column {
487+ {
488+ Name : "_cq_id" ,
489+ Type : types .ExtensionTypes .UUID ,
490+ Description : "Internal CQ ID of the row" ,
491+ NotNull : true ,
492+ },
493+ {Name : "bool" , Type : arrow .FixedWidthTypes .Boolean , PrimaryKey : true },
494+ },
495+ },
496+ source : & Table {
497+ Name : "test" ,
498+ Columns : []Column {
499+ {
500+ Name : "_cq_id" ,
501+ Type : types .ExtensionTypes .UUID ,
502+ Description : "Internal CQ ID of the row" ,
503+ NotNull : true ,
504+ Unique : true ,
505+ },
506+ {Name : "bool" , Type : arrow .FixedWidthTypes .Boolean , PrimaryKey : true },
507+ },
508+ },
509+ expectedChanges : []TableColumnChange {
510+ {
511+ Type : TableColumnChangeTypeRemoveUniqueConstraint ,
512+ ColumnName : "_cq_id" ,
513+ Previous : Column {
514+ Name : "_cq_id" ,
515+ Type : types .ExtensionTypes .UUID ,
516+ Description : "Internal CQ ID of the row" ,
517+ NotNull : true ,
518+ Unique : true ,
519+ },
520+ },
521+ },
522+ },
348523}
349524
350525func TestTableGetChanges (t * testing.T ) {
0 commit comments