Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the "change"-function #39

Closed
4ice opened this issue Oct 21, 2022 · 8 comments · Fixed by #88
Closed

Add support for the "change"-function #39

4ice opened this issue Oct 21, 2022 · 8 comments · Fixed by #88
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@4ice
Copy link

4ice commented Oct 21, 2022

It would be great if this feature was supported.

As I understand, the following would have to be done in order to change a field (This example changes a field called "name" from a varchar to text):

  1. Add a column of the desired type (ALTER TABLE table_name ADD COLUMN field2 TEXT CHARACTER SET utf8mb4 DEFAULT NULL COLLATE utf8mb4_unicode_ci; )
  2. Fill values in this column with the column you want to change the data type (UPDATE table_name SET name2 = name;)
  3. Remove the previous column (ALTER TABLE table_name DROP COLUMN name;)
  4. Change the name of the new column (ALTER TABLE table_name CHANGE name2 name;)

Would it be possible to implement this? Or is there already another way to do this?

@carlsverre
Copy link
Contributor

Does Laravel have a change function already that works with other database backends or are you just suggesting that this pattern should be made into a nice function?

@4ice
Copy link
Author

4ice commented Oct 26, 2022

@carlsverre Yes, the function exists and works with other databases. I am migrating from mysql driver to singlestore, and I have several migrations that use the change()-function that I am working on rewriting as we speak.

@carlsverre
Copy link
Contributor

Gotcha. This is a great feature request. Thank you!

@carlsverre carlsverre added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Oct 26, 2022
@sneycampos
Copy link

Hi, any news about this issue/feature request?

@JackEllis
Copy link

@carlsverre I like this suggestion. Can this all be done in a single SQL DB transaction?

@carlsverre
Copy link
Contributor

Unfortunately alter tables in SingleStore don't operate within user defined transactions. So it's not possible to perform this entire column change process atomically.

danmatthews added a commit to danmatthews/singlestoredb-psudo-mysql-laravel-driver that referenced this issue Aug 2, 2023
Add some readme bits for singlestore-labs#39 until support is defined for that method.
@hafezdivandari
Copy link
Contributor

hafezdivandari commented Jul 13, 2024

Is this issue still relevant? It's easy to implement this using the OP's workaround: adding, inserting, dropping, renaming.

@hafezdivandari
Copy link
Contributor

You may check PR #88

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants