Repository navigation
Conversation
| require ( | ||
| github.com/brianvoe/gofakeit/v7 v7.17.1 | ||
| github.com/cerberauth/x v0.0.0-20260901215913-9d7750841dbb | ||
| github.com/microsoft/go-mssqldb v1.9.2 |
There was a problem hiding this comment.
go.sum isn’t in the diff. Please run go mod tidy and commit both files. Consider putting azuread behind a build tag so the default binary doesn’t carry the Azure SDK.
There was a problem hiding this comment.
This 1,400-line patch of the PR’s own changes looks committed by accident. Please remove it.
| } | ||
| } | ||
|
|
||
| func bytesText(b []byte) string { |
There was a problem hiding this comment.
Treating all-printable-ASCII bytes as text will misread some raw salts. A 4-byte salt has about a 1.9% chance and an 8-byte one about 0.04%, so over a million users that’s hundreds of rows. Those rows get a wrong salt, so the migrated passwords won’t verify. Please always hex-encode VARBINARY/BINARY/BLOB/bytea columns, and have users CAST to text for stored bcrypt strings.
| - **`--query`** is the SQL, or `@file.sql` to read it from a file. It returns one row per user. | ||
| - **`--mapping`** renames the columns into the ones iamigrate reads, as for a [flat file](../../../reference/cli/prepare/). A query that already names its columns `source_id`, `email`, `password`... needs none. | ||
|
|
||
| Rows are read as they arrive and handed on in batches of 1,000, so memory doesn't grow with the number of users. The query runs in a transaction that is rolled back at the end: nothing is written. |
There was a problem hiding this comment.
“Rolled back, nothing is written” isn’t reliable. On SQL Server, …; COMMIT; DELETE … commits its own writes. On SQLite, PRAGMA query_only can be switched off by the query itself, if the driver runs more than one statement. Please reword the guide and open SQLite with mode=ro.
| manifest.NonPortableMFACounts = map[cmf.MFAType]int{} | ||
| } | ||
|
|
||
| rows, positions, dropped, err := exportRecord(ctx, rows, opts.Mapping) |
There was a problem hiding this comment.
exportRecord still keys hooks with recordKey(i), where i is the index inside the batch. So an export.record handler sees record 1…1000 again in every batch, while id.source sees the shifted numbers. Please pass offset into exportRecord and use recordKey(offset+i). Also, detectHashes only catches duplicate source_ids within one batch.
| golang.org/x/term v0.46.0 | ||
| gopkg.in/dnaeon/go-vcr.v3 v3.2.0 | ||
| gopkg.in/yaml.v3 v3.0.1 | ||
| modernc.org/sqlite v1.38.2 |
There was a problem hiding this comment.
why do you need this mod?
|
Hi @vmose, Thanks for the contribution! I’ve left some review comments. Could you please make the requested changes when you have time? Happy to help if anything is unclear. |
Add the
sqlserverdriver forexport --source sqlRegisters Microsoft SQL Server (and Azure SQL) as an engine for
iamigrate export --source sql, on top of #90.What changed
--driver sqlserverthrough go-mssqldb, with the engine's standard DSN (URL orkey=valueform), handed to the driver untouched.encrypt,TrustServerCertificate,certificate,hostNameInCertificate). No iamigrate-side settings.varbinarycolumns are read as bytes. Printable ASCII (a bcrypt string stored as bytes) stays text; anything else is hex, sopassword_encoding/password_salt_encodingapply as for flat files.uniqueidentifiercomes out as a lower-case UUID rather than SQL Server's byte order.fedauth=parameter in the DSN switches to go-mssqldb'sazureaddriver; without it, a SQL login uses the plain driver.sys.databases.snapshot_isolation_state); otherwise the default isolation, with a notice in the progress line.varbinary/GUID, snapshot on and off, TLS from the DSN), plus unit tests for Entra DSN detection. NewsqlserverCI job using a service container;.docker/sqlserver/docker-compose.ymlfor running it locally.docs/guides/export/sql.mdxwith an example query, TLS, Entra and isolation sections; CLI reference updated.Also in this PR (needed by the above)
If #90 is not merged yet, this PR carries its core: the
sqlconnector and driver registry,--driver/--dsn/--query, the SQLite driver (pure Go, no cgo), andflatfile.ExportRows, a refactor offlatfile'sExportso the same mapping pipeline can run per batch.Export's behaviour is unchanged.Not included
--memberships-query(Organizations, roles and memberships from flat files #89),job create --source sql, and secret references for the DSN, which are Generic SQL source: export users from a database query through mapping.yaml #90 items.db_datareader).Reviewer notes
azureadpulls in the Azure SDK, which noticeably enlarges the binary. If that is a concern, the Entra driver can move behind a build tag.Test plan
Closes #