client-ts icon indicating copy to clipboard operation
client-ts copied to clipboard

[Importer] Add `keep-existing-columns` flag

Open SferaDev opened this issue 1 year ago • 6 comments

Add new flag keep-existing-columns to merge an existing table columns with the parsed types

  • In the case that the guessed type is different, we don't prompt for a migration, the import will attempt to coerce the value instead and will fail if not able to coerce it

SferaDev avatar Jul 12 '23 05:07 SferaDev

⚠️ No Changeset found

Latest commit: d0c81b8f14eff42a0e660fc263421bee97e3d9ab

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Jul 12 '23 05:07 changeset-bot[bot]

size-limit report 📦

Path Size
packages/client/dist/index.mjs 16.08 KB (0%)
packages/client/dist/index.cjs 17.27 KB (0%)
packages/codegen/dist/index.mjs 2.55 MB (0%)
packages/codegen/dist/index.cjs 2.56 MB (0%)

github-actions[bot] avatar Jul 12 '23 05:07 github-actions[bot]

Your pull request has been published to npm.

You can install @xata.io/client by running:

npm install @xata.io/[email protected]

Other packages are published like this:

npm install @xata.io/[email protected]

To test the CLI, run:

npx @xata.io/[email protected]

github-actions[bot] avatar Jul 12 '23 05:07 github-actions[bot]

Tried it out, some feedback:

with the existing table schema having brokerage as link, the CLI suggests to remove the link column (brokerage)

id,licenseNumber,licenseHolderName,licenseType,stateLicenseType,brokerage,licenseExpirationDate,address1,address2,city,county,zip,state
1,license1,name1,type1,state1,broker1,2023-07-10T16:04:33.932152Z,addr1,addr2,ny,us,16232,california
xataCli import csv agentities.csv --table=agent
✖ WARNING: The following columns will be removed and you will lose data. brokerage. 
Do you want to continue? …

(This doesn't happen with --keep-existing-columns)

kostasb avatar Jul 12 '23 07:07 kostasb

Yeah, without the flag it will try to remove the link column and create an int one, this is the new default behaviour that @richardgill implemented with the new importer. There could be a discussion about if that should be the default or not, no strong preferences in this case (because we have a flag for both cases), up to @richardgill

SferaDev avatar Jul 12 '23 07:07 SferaDev

We can provide a hint to use the flag keep-existing-columns in this warning message then?

kostasb avatar Jul 12 '23 07:07 kostasb