From 19deb9141d82826a6892d690a5c0b39a18fa39e6 Mon Sep 17 00:00:00 2001 From: "Hugh A. Miles II" Date: Thu, 29 Jun 2023 16:23:48 -0400 Subject: [PATCH] feat: add description column to Tags (#24553) --- ...23c7f86f_update_tag_model_w_description.py | 39 +++++++++++++++++++ superset/tags/models.py | 3 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 superset/migrations/versions/2023-06-29_18-38_240d23c7f86f_update_tag_model_w_description.py diff --git a/superset/migrations/versions/2023-06-29_18-38_240d23c7f86f_update_tag_model_w_description.py b/superset/migrations/versions/2023-06-29_18-38_240d23c7f86f_update_tag_model_w_description.py new file mode 100644 index 0000000000..84a2e68754 --- /dev/null +++ b/superset/migrations/versions/2023-06-29_18-38_240d23c7f86f_update_tag_model_w_description.py @@ -0,0 +1,39 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +"""update_tag_model_w_description + +Revision ID: 240d23c7f86f +Revises: 6fbe660cac39 +Create Date: 2023-06-29 18:38:30.033529 + +""" + +# revision identifiers, used by Alembic. +revision = "240d23c7f86f" +down_revision = "6fbe660cac39" + +import sqlalchemy as sa +from alembic import op +from sqlalchemy.dialects import postgresql + + +def upgrade(): + op.add_column("tag", sa.Column("description", sa.Text(), nullable=True)) + + +def downgrade(): + op.drop_column("tag", "description") diff --git a/superset/tags/models.py b/superset/tags/models.py index d7feb4f48c..87670a0d29 100644 --- a/superset/tags/models.py +++ b/superset/tags/models.py @@ -20,7 +20,7 @@ import enum from typing import TYPE_CHECKING from flask_appbuilder import Model -from sqlalchemy import Column, Enum, ForeignKey, Integer, String +from sqlalchemy import Column, Enum, ForeignKey, Integer, String, Text from sqlalchemy.engine.base import Connection from sqlalchemy.orm import relationship, Session, sessionmaker from sqlalchemy.orm.mapper import Mapper @@ -76,6 +76,7 @@ class Tag(Model, AuditMixinNullable): id = Column(Integer, primary_key=True) name = Column(String(250), unique=True) type = Column(Enum(TagTypes)) + description = Column(Text) objects = relationship( "TaggedObject", back_populates="tag", overlaps="objects,tags"