jackc / tern

The SQL Fan's Migrator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Migrations not actually run in a transaction?

Preetam opened this issue · comments

Reading the code for migration, it looks like a transaction is started here:

tx, err = m.conn.Begin(ctx)

but tx is not actually used to execute the SQL, so the migration is not actually run within a transaction.

_, err = m.conn.Exec(ctx, sql)

@jackc: Am I reading that wrong or is there a bug here?

Oh, is it because there is no connection pooling so everything's happening in the same connection?

Yes. Since it is a single connection it will be correctly executed even though the code does look suspicious. That code could be made clearer. But I'm also hoping to eliminate explicit transaction handling altogether. See #43.

Thanks!