flipboxfactory / saml-sp

SAML Service Provider (SP) Plugin for Craft CMS
https://saml-sp.flipboxfactory.com/
Other
19 stars 5 forks source link

Migration Error #188

Closed transopticmedia closed 1 year ago

transopticmedia commented 1 year ago

Version: 4.0.5 Craft CMS 4.3.5

I've had some stops and starts with this plugin––I installed it to start vetting wether it will work for us (we're using OKTA), then priorities changed, I uninstalled it, and now am trying to reinstall it to try again, but it seems the original table is still in the DB and interfering with the migration. I'd prefer not to edit the database manually to remove the table if I can avoid it.

An error occurred while executing the "flipbox\saml\sp\migrations\Install migration: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'saml_sp_providers' already exists

dsmrt commented 1 year ago

:wave: @transopticmedia

I've run some tests on uninstall for the plugin on Craft 4.3.5 and I didn't see any issues. All of the tables were deleted as expected. Do you have any errors from the uninstalling process that'd make you think it errored?

Unfortunately, you'll have to do some clean up to proceed with a fresh installation. Here are the tables created by the plugin. Please make sure the Keychain plugin is uninstalled as well. This plugin is a dependency. Backup your data in needed before deleting the following tables:

# saml_sp plugin tables
saml_sp_providers
saml_sp_provider_identity
saml_provider_keychain_link

# keychain tables
keychain
transopticmedia commented 1 year ago

Thanks, I appreciate you looking into this! I was able to delete the tables, no big deal. When I then try to install the plugin fresh, i get the following error about Foreign Key Constraint:

Migration Error: An error occurred while executing the "flipbox\saml\sp\migrations\Install migration: SQLSTATE[HY000]: General error: 1005 Can't create table mydb.saml_provider_keychain_link (errno: 150 "Foreign key constraint is incorrectly formed") The SQL being executed was: ALTER TABLE saml_provider_keychain_link ADD CONSTRAINT fk_olnghazcxerzrwemrolamyavjmjlnawaumox FOREIGN KEY (keyChainId) REFERENCES keychain (id) ON DELETE CASCADE

dsmrt commented 1 year ago

Are all of the tables I mentioned above deleted when you tried to reinstall them?

transopticmedia commented 1 year ago

Yes, and these three are re-installedeach time i try:

saml_sp_providers saml_sp_provider_identity saml_provider_keychain_link

The Keychain table doesn't show up. Not sure if this is relevant, but I installed this plugin the first time on Craft 3. Installing it on my DDEV installation worked, but ran into this issue with when deploying on our staging server.

dsmrt commented 1 year ago

Are you installing via composer or via the ui?

transopticmedia commented 1 year ago

I installed it through the UI in my local DDEV installation, then I checked in the updated Composer.json and Config and deploy (with DeployHQ) to my staging server where I run Composer Update, and Migrate All via SSH.

transopticmedia commented 1 year ago

Hi –– I finally got this working -- I'm sorry, it was totally something stupid on my part. I wasn't uninstalling the Keychain plugin, rather just deleting the table. That being said, your tip to delete those tables was very helpful in getting it sorted, and thank you. Now back to testing the plugin.

dsmrt commented 1 year ago

@transopticmedia let me know if there's anything I can help with!