dosubot[bot] commented on issue #29836:
URL: https://github.com/apache/superset/issues/29836#issuecomment-2265028803
<!-- Greeting -->
Hey @jinmengcheng! I'm here to help you with any bugs, questions, or
contributions you may have regarding the Superset upgrade. Let's work together
to solve this issue!
<!-- Answer -->
To resolve the issue of the `user_favorite_tag` table not being created when
upgrading Apache Superset from version 3.0.1 to 4.0.2 using Docker on MacOS,
you need to ensure that the Alembic migrations are applied correctly. Here are
the steps to follow:
1. **Ensure the migration script is in place**: Verify that the migration
script `2023-07-12_20-34_e0f6f91c2055_create_user_favorite_table.py` is located
in the correct directory within your Superset project, typically under
`superset/migrations/versions/`.
2. **Shut down running containers**: First, make sure to shut down the
running containers in Docker Compose:
```bash
docker compose down
```
3. **Update the Superset repository**: Update the folder that mirrors the
`superset` repo through git:
```bash
git pull origin master
```
4. **Restart the containers**: Restart the containers and any changed Docker
images will be automatically pulled down:
```bash
docker compose up
```
5. **Run the migration**: Execute the Alembic upgrade command to apply the
migrations. You can do this by running the following command inside your Docker
container:
```sh
docker exec -it <container_name> superset db upgrade
```
Replace `<container_name>` with the name of your Superset Docker
container.
6. **Initialize Superset**: Run the following command to initialize Superset:
```sh
docker exec -it <container_name> superset init
```
7. **Verify the table creation**: After running the migration, check your
database to ensure that the `user_favorite_tag` table has been created.
The `upgrade` function in the migration script should create the
`user_favorite_tag` table as follows:
```py
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"user_favorite_tag",
sa.Column("user_id", sa.Integer(), nullable=False),
sa.Column("tag_id", sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(
["tag_id"],
["tag.id"],
),
sa.ForeignKeyConstraint(
["user_id"],
["ab_user.id"],
),
)
# ### end Alembic commands ###
```
Additionally, ensure that the `user_favorite_tag` table is correctly defined
in your models. According to the `superset/tags/models.py` file, the table
should be defined as follows:
```py
user_favorite_tag_table = Table(
"user_favorite_tag",
Model.metadata, # pylint: disable=no-member
Column("user_id", Integer, ForeignKey("ab_user.id")),
Column("tag_id", Integer, ForeignKey("tag.id")),
)
```
If the table is still not created, ensure that there are no errors in the
migration script and that the database connection is properly configured
<sup>[[1]](https://github.com/apache/superset/blob/master/superset/migrations/versions/2023-07-12_20-34_e0f6f91c2055_create_user_favorite_table.py)</sup><sup>[[2]](https://github.com/apache/superset/blob/master/superset/tags/models.py)</sup><sup>[[3]](https://github.com/apache/superset/blob/master/docs/docs/installation/upgrading-superset.mdx)</sup>.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]