GitHub user dosubot[bot] added a comment to the discussion: Extend user profile in production
<!-- Greeting --> Hi @rtobi1204! I'm [Dosu](https://go.dosu.dev/dosubot) and Iām helping the superset team. <!-- Answer --> You **can** extend `ab_user` on a live instance ā the key misconception is that `superset db upgrade` only runs on first startup. It doesn't; you can run it manually at any time to apply pending migrations. Here's the approach: **1. Create your custom user model:** ```python from flask_appbuilder.security.sqla.models import User from sqlalchemy import Column, String class CustomUser(User): __tablename__ = "ab_user" group_id = Column(String(256)) ``` **2. Create a custom security manager** (must extend `SupersetSecurityManager`, not FAB's base class) [[1]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/initialization/__init__.py): ```python from superset.security import SupersetSecurityManager class CustomSecurityManager(SupersetSecurityManager): user_model = CustomUser ``` **3. Register it in `superset_config.py`** [[2]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/config.py): ```python from my_custom_security import CustomSecurityManager CUSTOM_SECURITY_MANAGER = CustomSecurityManager ``` **4. Create and run a migration for your live database.** You can either: - Write a custom Alembic migration script (placed in `superset/migrations/versions/`) that does `op.add_column("ab_user", sa.Column("group_id", sa.String(256), nullable=True))` - Or simply run the SQL directly against your metadata database: `ALTER TABLE ab_user ADD COLUMN group_id VARCHAR(256);` Then run [[3]](https://github.com/apache/superset/discussions/37261): ```bash superset db upgrade superset init # restart superset ``` The `superset db upgrade` command uses Alembic under the hood [[1]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/initialization/__init__.py) and applies any pending migrations ā it's not limited to first startup. **5. Use the custom attribute in an RLS filter clause:** ```sql group_id = '{{ current_user_attribute("group_id") }}' ``` RLS filters support Jinja templating for dynamic filtering based on user attributes [[4]](https://github.com/apache/superset/pull/29884). **Tips for production:** - Test the migration on a staging environment first - For large instances, plan for potential downtime during migration [[3]](https://github.com/apache/superset/discussions/37261) - If you hit foreign key constraint errors during migration, check for orphaned records [[5]](https://github.com/apache/superset/discussions/38286#discussioncomment-15943132) - Make sure to use `nullable=True` for the new column so existing users aren't affected <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).* --- Share context across your team and agents. Try [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-tagline&utm_term=apache%2Fsuperset). [](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-feedback&utm_term=apache%2Fsuperset&message_id=21cfd761-a09f-46d9-b927-c77f1231631a) [](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-learn-repo&utm_term=apache%2Fsuperset) [](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-add-team&utm_term=apache%2Fsuperset) GitHub link: https://github.com/apache/superset/discussions/40025#discussioncomment-16880658 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
