GitHub user dosubot[bot] added a comment to the discussion: Unable to migrate db

<!-- Greeting -->
Hi @EsDmitrii! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the 
superset team.

<!-- Answer -->
The error you're seeing during the migration (`cannot drop type tagtypes 
because other objects depend on it`) indicates a dependency issue in your 
database schema, not that Superset is trying to drop all tables or reinitialize 
the database from scratch. The `superset db upgrade` command applies Alembic 
migrations to update your schema incrementally; it does not wipe your data or 
drop all objects, but specific migrations may attempt to alter or drop types, 
tables, or columns as needed for the new version's schema requirements. The 
error suggests that a migration is trying to drop a type (`tagtypes`) that is 
still in use by a column in the `tag` table, which PostgreSQL does not allow 
unless you use `CASCADE` (which would also drop dependent columns or tables, 
potentially causing data loss).

To migrate without data loss, consider these approaches:

1. **Incremental Upgrades**: Try upgrading to intermediate major versions (for 
example, 2.1.0 → 3.x.x → 4.1.2) instead of jumping directly to 4.1.2. This can 
help isolate where the migration fails and may avoid some breaking changes that 
are not handled well in a direct upgrade. This approach has been suggested by 
maintainers in similar situations and has helped others narrow down and resolve 
migration issues [(source)](https://github.com/apache/superset/issues/32342).

2. **Manual Intervention**: Before running the migration, inspect your database 
for objects that depend on the `tagtypes` type. You may need to manually update 
or drop/recreate the dependent columns or tables, or adjust the migration 
script to handle the dependency more gracefully. Be sure to back up your 
database before making manual changes.

3. **Legacy Import**: Superset 4.x.x provides a `legacy_import_datasources` 
command, which allows you to export your datasources from the old version and 
import them into the new version using JSON files. This can be a safer way to 
migrate your data if schema migrations are problematic. The command expects a 
JSON or directory of JSONs and can be run as follows:
   ```
   superset legacy_import_datasources -p <path or filename>
   ```
   You can specify a user with `-u` and use `-r` for recursive import 
[(source)](https://github.com/apache/superset/blob/master/docs/docs/configuration/importing-exporting-datasources.mdx).

4. **Check for Problematic Datasets**: In some cases, specific datasets or 
objects in your database may cause migration failures. Identifying and removing 
or fixing these before migration can allow the upgrade to proceed 
[(source)](https://github.com/apache/superset/issues/32342).

The error you encountered is not typical for a standard migration and likely 
results from a schema customization or legacy artifact in your database. Always 
back up your database before attempting migrations or manual fixes.

If you continue to encounter issues, consider reviewing the specific migration 
scripts involved and the changelogs for relevant fixes and breaking changes in 
each major version 
[(source)](https://github.com/apache/superset/blob/master/CHANGELOG/4.1.2.md), 
[(source)](https://github.com/apache/superset/blob/master/CHANGELOG/4.1.0.md).


<!-- Dosu Comment Footer -->
*To reply, just mention my name [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/d30adb73-9129-4520-a732-1c6d3aff68be?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/d30adb73-9129-4520-a732-1c6d3aff68be?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/d30adb73-9129-4520-a732-1c6d3aff68be?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/d30adb73-9129-4520-a732-1c6d3aff68be?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/d30adb73-9129-4520-a732-1c6d3aff68be?feedback_type=hallucination)
 | [Report 
šŸ›](https://app.dosu.dev/response-feedback/d30adb73-9129-4520-a732-1c6d3aff68be?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/d30adb73-9129-4520-a732-1c6d3aff68be?feedback_type=other)</sup>&nbsp;&nbsp;[![Join
 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Sh
 are on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/33616)

GitHub link: 
https://github.com/apache/superset/discussions/33616#discussioncomment-13308981

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: 
notifications-unsubscr...@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to