<commit_before>package migo

import (
	"fmt"

	"github.com/pkg/errors"

	schema "github.com/lestrrat/go-jsschema"
)

type ForeignKey struct {
	Name          string                 `json:"name"`
	SourceTable   Table                  `json:"source_table"`
	SourceColumn  Column                 `json:"source_column"`
	TargetTable   Table                  `json:"target_table"`
	TargetColumn  Column                 `json:"column"`
	UpdateCascade bool                   `json:"update_cascade"`
	DeleteCascade bool                   `json:"delete_cascade"`
	Raw           map[string]interface{} `json"-"`
}
type ForeignKeys []ForeignKey

func (k ForeignKeys) Len() int {
	return len(k)
}

func (k ForeignKeys) Less(i, j int) bool {
	return k[i].Name < k[j].Name
}

func (k ForeignKeys) Swap(i, j int) {
	k[i], k[j] = k[j], k[i]
}

func NewForeignKey(sourceTable Table, sourceColumn Column) ForeignKey {
	return ForeignKey{
		SourceColumn: sourceColumn,
		SourceTable:  sourceTable,
	}
}

func (fk *ForeignKey) read(s schema.Schema) error {
	if !hasForeignKey(s) {
		return errors.New("foreign not found")
	}

	m, ok := s.Extras["column"].(map[string]interface{})<commit_msg>fix json tag<commit_after>package migo

import (
	"fmt"

	"github.com/pkg/errors"

	schema "github.com/lestrrat/go-jsschema"
)

type ForeignKey struct {
	Name          string                 `json:"name"`
	SourceTable   Table                  `json:"source_table"`
	SourceColumn  Column                 `json:"source_column"`
	TargetTable   Table                  `json:"target_table"`
	TargetColumn  Column                 `json:"column"`
	UpdateCascade bool                   `json:"update_cascade"`
	DeleteCascade bool                   `json:"delete_cascade"`
	Raw           map[string]interface{} `json:"-"`
}
type ForeignKeys []ForeignKey

func (k ForeignKeys) Len() int {
	return len(k)
}

func (k ForeignKeys) Less(i, j int) bool {
	return k[i].Name < k[j].Name
}

func (k ForeignKeys) Swap(i, j int) {
	k[i], k[j] = k[j], k[i]
}

func NewForeignKey(sourceTable Table, sourceColumn Column) ForeignKey {
	return ForeignKey{
		SourceColumn: sourceColumn,
		SourceTable:  sourceTable,
	}
}

func (fk *ForeignKey) read(s schema.Schema) error {
	if !hasForeignKey(s) {
		return errors.New("foreign not found")
	}

	m, ok := s.Extras["column"].(map[string]interface{})
{'fraction_non_alphanumeric': 0.12777777777777777, 'fraction_numerical': 0.0, 'mean_word_length': 2.85667215815486, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1249188', 'n_tokens_mistral': 785, 'n_tokens_neox': 761, 'n_words': 183}