<commit_before><commit_msg>Tabela de usuarios - id do usuario na tabela de professor e aluno - o user name é o cpf - o cpf é unico na tabela de usuarios<commit_after>USE mytcc;

CREATE TABLE IF NOT EXISTS `usuario` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user` varchar(50) NOT NULL,
  `senha` varchar(50) NOT NULL,
  `tipo` char(1) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `user` (`user`)
);

ALTER TABLE aluno
ADD COLUMN cpf VARCHAR(9);

ALTER TABLE aluno ADD
UNIQUE KEY cpf (cpf);

ALTER TABLE professor
ADD COLUMN cpf VARCHAR(9);

ALTER TABLE professor ADD
UNIQUE KEY cpf (cpf);

UPDATE aluno
SET cpf = left(concat(matricula, '', '000000'), 9)
WHERE id <> -1;

UPDATE professor
SET cpf = right(concat('000000', '', matricula), 9)
WHERE id <> -1;

ALTER TABLE aluno
MODIFY COLUMN cpf VARCHAR(9) NOT NULL;

ALTER TABLE professor
MODIFY COLUMN cpf VARCHAR(9) NOT NULL;

INSERT INTO usuario
	SELECT
		NULL,
		cpf,
        '123',
        CAST('a' AS CHAR(1))
	FROM aluno;

INSERT INTO usuario
	SELECT
		NULL,
		cpf,
        '123',
        CAST('p' AS CHAR(1))
	FROM professor;

ALTER TABLE aluno
ADD COLUMN idUsuario int(11);

ALTER TABLE professor
ADD COLUMN idUsuario int(11);

UPDATE aluno
INNER JOIN usuario
	ON usuario.user = aluno.cpf
SET aluno.idUsuario = usuario.id;

UPDATE professor
INNER JOIN usuario
	ON usuario.user = professor.cpf
SET professor.idUsuario = usuario.id;

ALTER TABLE aluno
MODIFY COLUMN idUsuario int(11) NOT NULL;

ALTER TABLE professor
MODIFY COLUMN idUsuario int(11) NOT NULL;
{'fraction_non_alphanumeric': 0.09636963696369637, 'fraction_numerical': 0.02838283828382838, 'mean_word_length': 3.954248366013072, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5545935', 'n_tokens_mistral': 612, 'n_tokens_neox': 580, 'n_words': 203}