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

sqlite drop column #943

Open
nextonphotos opened this issue Jun 28, 2024 · 1 comment
Open

sqlite drop column #943

nextonphotos opened this issue Jun 28, 2024 · 1 comment

Comments

@nextonphotos
Copy link

I can't seem to find a good way to drop a column in sqlite. Dropping a column with SQL is only supported in newer versions of sqlite than what some of the servers I have to work with support.

A comment in SQLiteWriter says, "In SQLite we can't change columns, drop columns, change or add foreign keys so we have a table-rebuild function."

There are functions available to do some of these things using get and put table, but I can't figure out how to drop a column. What am I missing? Any suggestions on how to do this, or is this functionality currently not available?

@Lynesth
Copy link
Collaborator

Lynesth commented Jun 29, 2024

RedBeanPHP isn't responsible for what's available or not in SQLite version and does not provide any polyfill for missing features, unless those would be fundamental for RedBean's inner workings.

If your SQLite version doesn't support DROP COLUMN, then you'll have to create a new table, copy the data, delete the old table and rename the new one.
You can find examples online as to how you can do this, such as this one on SO: https://stackoverflow.com/questions/5938048/drop-column-from-sqlite-table/5987838#5987838

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants