<commit_before>package service

import (
	"database/sql"
	_ "github.com/mattn/go-sqlite3"
)

type ServiceBinding struct {
	ServiceConfigId int
	AppId           int
	UserId          int
	BindingTokenId  int
	Name            string
}

func (s *ServiceBinding) Create() {
	db, _ := sql.Open("sqlite3", "./tsuru.db")
	defer db.Close()

	query := "INSERT INTO service_bindings (service_config_id, app_id, user_id, binding_token_id, name) VALUES (?, ?, ?, ?, ?)"
	insertStmt, err := db.Prepare(query)
	if err != nil {
		panic(err)
	}

	tx, err := db.Begin()
	if err != nil {
		panic(err)
	}

	stmt := tx.Stmt(insertStmt)
	stmt.Exec(s.ServiceConfigId, s.AppId, s.UserId, s.BindingTokenId, s.Name)
	tx.Commit()
}<commit_msg>Creating service unit on service's creation<commit_after>package service

import (
	"database/sql"
	_ "github.com/mattn/go-sqlite3"
	"github.com/timeredbull/tsuru/api/unit"
)

type ServiceBinding struct {
	ServiceConfigId int
	AppId           int
	UserId          int
	BindingTokenId  int
	Name            string
}

func (s *ServiceBinding) Create() {
	db, _ := sql.Open("sqlite3", "./tsuru.db")
	defer db.Close()

	query := "INSERT INTO service_bindings (service_config_id, app_id, user_id, binding_token_id, name) VALUES (?, ?, ?, ?, ?)"
	insertStmt, err := db.Prepare(query)
	if err != nil {
		panic(err)
	}

	tx, err := db.Begin()
	if err != nil {
		panic(err)
	}

	stmt := tx.Stmt(insertStmt)
	stmt.Exec(s.ServiceConfigId, s.AppId, s.UserId, s.BindingTokenId, s.Name)
	tx.Commit()

	u := unit.Unit{Name: s.Name, Type: "mysql"}
	err = u.Create()
}
{'fraction_non_alphanumeric': 0.14869176770899808, 'fraction_numerical': 0.0025526483726866626, 'mean_word_length': 3.4545454545454546, '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': '5733909', 'n_tokens_mistral': 608, 'n_tokens_neox': 600, 'n_words': 131}