<commit_before># -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models


class Migration(SchemaMigration):

    def forwards(self, orm):

        db.execute('''
            TRUNCATE TABLE column_attributes;
            INSERT INTO column_attributes
            (table_name, column_name, display_name, display_on_table_flag)

            SELECT
            	table_name
            	, column_name
            	, replace(column_name, '_', ' ') as display_name
            	, CAST(0 AS BOOLEAN)
            FROM information_schema.columns isc
            INNER JOIN django_content_type dct
            	ON replace(table_name, '_', '') = dct.model
            WHERE table_schema = 'public'

            UNION ALL

            SELECT
            	table_name
            	, column_name
            	, replace(column_name, '_', ' ') as display_name
            	, CAST(0 AS BOOLEAN)
            FROM information_schema.columns isc
            WHERE table_name
            in ('auth_user_groups'
                ,'pg_auth_members'
                ,'administrable_role_authorizations'
                ,'auth_user'<commit_msg>tweaking migration for attribute metadata<commit_after># -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models


class Migration(SchemaMigration):

    def forwards(self, orm):

        db.execute('''
            TRUNCATE TABLE column_attributes;
            INSERT INTO column_attributes
            (table_name, column_name, display_name, display_on_table_flag)

            SELECT
            	table_name
            	, column_name
            	, replace(column_name, '_', ' ') as display_name
            	, CAST(0 AS BOOLEAN)
            FROM information_schema.columns isc
            INNER JOIN django_content_type dct
            	ON replace(table_name, '_', '') = dct.model
            WHERE table_schema = 'public'

            UNION ALL

            SELECT
            	  replace(table_name, 'auth_', '') as table_name
            	, column_name
            	, replace(column_name, '_', ' ') as display_name
            	, CAST(0 AS BOOLEAN)
            FROM information_schema.columns isc
            WHERE table_name
            in ('auth_user_groups'
                ,'pg_auth_members'
                ,'administrable_role_authorizations'
                ,'auth_user'
{'fraction_non_alphanumeric': 0.07239459029435164, 'fraction_numerical': 0.0031821797931583136, 'mean_word_length': 1.8354002254791433, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5038453', 'n_tokens_mistral': 696, 'n_tokens_neox': 663, 'n_words': 166}