Repository: ariga/atlas (go)

Issue:
sqlite: migration output for column default value incorrectly strips parentheses
### Background
From https://www.sqlite.org/lang_createtable.html#the_default_clause:
> If the default value of a column is an expression in parentheses, then the expression is evaluated once for each row inserted and the results used in the new row.

### Repro
Given this desired schema:
```sql
create table users (
  id text not null default (uuid()),
  primary key (id)
);
```

### Actual result
`atlas migrate diff` will generate:
```sql
CREATE TABLE `users` (`id` text NOT NULL DEFAULT uuid(), PRIMARY KEY (`id`));
```

Note the `uuid()` has the parentheses stripped, which sqlite will not accept as a valid default:
```sql
Parse error: near "(": syntax error
  ATE TABLE `users` (`id` text NOT NULL DEFAULT uuid(),
                                      error here ---^
```

### Expected result
The output migration should keep the parentheses, i.e.
```sql
CREATE TABLE `users` (`id` text NOT NULL DEFAULT (uuid()), PRIMARY KEY (`id`));
```

Pull request description:
sql/sqlite: ensure default expressions are wrapped
Fixed #2124 

Patch:
diff --git a/sql/sqlite/migrate.go b/sql/sqlite/migrate.go
index 562d4fb7..cba8f810 100644
--- a/sql/sqlite/migrate.go
+++ b/sql/sqlite/migrate.go
@@ -585,7 +585,7 @@ func defaultValue(c *schema.Column) (string, error) {
 			return sqlx.SingleQuote(x.V)
 		}
 	case *schema.RawExpr:
-		return x.X, nil
+		return sqlx.MayWrap(x.X), nil
 	default:
 		return "", fmt.Errorf("unexpected default value type: %T", x)
 	}


Test patch:
diff --git a/internal/integration/sqlite_test.go b/internal/integration/sqlite_test.go
index 108eefa6..863e70b8 100644
--- a/internal/integration/sqlite_test.go
+++ b/internal/integration/sqlite_test.go
@@ -224,7 +224,7 @@ func TestSQLite_AddColumns(t *testing.T) {
 			&schema.Column{Name: "null_real", Type: &schema.ColumnType{Type: &schema.FloatType{T: "real"}, Null: true}},
 			&schema.Column{Name: "notnull_real", Type: &schema.ColumnType{Type: &schema.FloatType{T: "real"}}, Default: &schema.Literal{V: "1.0"}},
 			&schema.Column{Name: "null_text", Type: &schema.ColumnType{Type: &schema.StringType{T: "text"}, Null: true}},
-			&schema.Column{Name: "notnull_text1", Type: &schema.ColumnType{Type: &schema.StringType{T: "text"}}, Default: &schema.RawExpr{X: "hello"}},
+			&schema.Column{Name: "notnull_text1", Type: &schema.ColumnType{Type: &schema.StringType{T: "text"}}, Default: &schema.Literal{V: "hello"}},
 			&schema.Column{Name: "notnull_text2", Type: &schema.ColumnType{Type: &schema.StringType{T: "text"}}, Default: &schema.Literal{V: "'hello'"}},
 			&schema.Column{Name: "null_blob", Type: &schema.ColumnType{Type: &schema.BinaryType{T: "blob"}, Null: true}},
 			&schema.Column{Name: "notnull_blob", Type: &schema.ColumnType{Type: &schema.BinaryType{T: "blob"}}, Default: &schema.Literal{V: "'blob'"}},
diff --git a/sql/sqlite/migrate_test.go b/sql/sqlite/migrate_test.go
index 759c1b13..0dc18210 100644
--- a/sql/sqlite/migrate_test.go
+++ b/sql/sqlite/migrate_test.go
@@ -232,6 +232,7 @@ func TestPlanChanges(t *testing.T) {
 							schema.NewIntColumn("id", "bigint"),
 							schema.NewIntColumn("rank", "int").SetDefault(&schema.Literal{V: "1"}),
 							schema.NewStringColumn("nick", "text").SetDefault(&schema.Literal{V: "a8m"}),
+							schema.NewStringColumn("expr", "text").SetDefault(&schema.RawExpr{X: "hex(1)"}),
 						},
 						Attrs: []schema.Attr{
 							&schema.Check{Expr: "(id <> 0)"},
@@ -264,8 +265,8 @@ func TestPlanChanges(t *testing.T) {
 				Transactional: true,
 				Changes: []*migrate.Change{
 					{Cmd: "PRAGMA foreign_keys = off"},
-					{Cmd: "CREATE TABLE `new_users` (`id` bigint NOT NULL, `rank` int NOT NULL DEFAULT 1, `nick` text NOT NULL DEFAULT 'a8m', CHECK (id <> 0))", Reverse: "DROP TABLE `new_users`"},
-					{Cmd: "INSERT INTO `new_users` (`id`, `rank`, `nick`) SELECT `id`, IFNULL(`rank`, 1) AS `rank`, IFNULL(`nick`, 'a8m') AS `nick` FROM `users`"},
+					{Cmd: "CREATE TABLE `new_users` (`id` bigint NOT NULL, `rank` int NOT NULL DEFAULT 1, `nick` text NOT NULL DEFAULT 'a8m', `expr` text NOT NULL DEFAULT (hex(1)), CHECK (id <> 0))", Reverse: "DROP TABLE `new_users`"},
+					{Cmd: "INSERT INTO `new_users` (`id`, `rank`, `nick`, `expr`) SELECT `id`, IFNULL(`rank`, 1) AS `rank`, IFNULL(`nick`, 'a8m') AS `nick`, `expr` FROM `users`"},
 					{Cmd: "DROP TABLE `users`"},
 					{Cmd: "ALTER TABLE `new_users` RENAME TO `users`"},
 					{Cmd: "PRAGMA foreign_keys = on"},