5
respostas

[Bug] Tabela não criada no Postgres(Aula 2)

Depois de rodar o docker-compose up verifiquei que a tabela não estava sendo criada no banco de dados postgres.

No terminal, notei que o compose up tinha o seguinte log:

psql: error: /docker-entrypoint-initdb.d/docker-database-initial.sql: Operation not permitted

Alguém com problema parecido?

5 respostas

Olá Kaio, tudo bem?

Você está no Linux?

Por favor, tente executar os seguintes comandos para ajustar o permissionamento do diretório e arquivo, caso esteja usando Linux como seu sistema hospedeiro para o Docker, rode o comando no terminal, estando no path onde esta o diretório do docker-database-initial.sql

chmod 775 -R <diretório do docker-database-initial.sql>

Caso esteja no Windows, abra as propriedades da pasta onde está o docker-database-initial.sql, vá em segurança e ajuste as permissões para que qualquer um possa ler, escrever e editar a pasta.

Suba a stack com o docker-compose up novamente

Obrigado pela sugestão

Estou no MacOS. Tem alguma diferença pra esse comando no Linux?

Tô tomando esse erro mesmo o path estando correto e o arquivo/past existirem:

 ✘ kaiocunha@Kaios-MacBook-Pro  ~/Desktop/projects/git/go/api-go-rest  ↱ master ±  chmod 775 -R migration 
chmod: -R: No such file or directory
 ✘ kaiocunha@Kaios-MacBook-Pro  ~/Desktop/projects/git/go/api-go-rest  ↱ master  chmod 775 -R migration/docker-database-initial.sql 
chmod: -R: No such file or directory
 ✘ kaiocunha@Kaios-MacBook-Pro  ~/Desktop/projects/git/go/api-go-rest  ↱ master  

Opa, tenta rodar o comando com o path completo, exemplo:

chmod 775 -R ~/Desktop/projects/git/go/api-go-rest/migration/docker-database-initial.sql 

Tentei também, e todas essas combinações:

 ✘ kaiocunha@Kaios-MacBook-Pro  ~  chmod 775 -R Desktop/projects/git/go/api-go-rest/migration/                              
chmod: -R: No such file or directory
 ✘ kaiocunha@Kaios-MacBook-Pro  ~  chmod 775 -R Desktop/projects/git/go/api-go-rest/migration/docker-database-initial.sql
chmod: -R: No such file or directory
 ✘ kaiocunha@Kaios-MacBook-Pro  ~  cat Desktop/projects/git/go/api-go-rest/migration/docker-database-initial.sql
create table wikis(
    id serial primary key,
    name varchar,
    bio varchar
);

INSERT INTO wikis(name, bio) VALUES
('Maynard Keynes', 'John Maynard Keynes, 1st Baron Keynes, CB, FBA, was an English economist whose ideas fundamentally changed the theory and practice of macroeconomics and the economic policies of governments. Originally trained in mathematics, he built on and greatly refined earlier work on the causes of business cycles.'),
('Flannery OConnor', 'Mary Flannery OConnor was an American novelist, short story writer and essayist. She wrote two novels and 31 short stories, as well as a number of reviews and commentaries.'),
('Ayrton Senna', 'Ayrton Senna da Silva was a Brazilian racing driver who won the Formula One World Drivers Championship in 1988, 1990, and 1991. Senna is one of three Formula One drivers from Brazil to win the World Championship and won 41 Grands Prix and 65 pole positions, with the latter being the record until 2006.');
 kaiocunha@Kaios-MacBook-Pro  ~  chmod 775 -R Desktop/projects/git/go/api-go-rest/migration/docker-database-initial.sql
chmod: -R: No such file or directory
 ✘ kaiocunha@Kaios-MacBook-Pro  ~  cd docker-database-initial.sql
 ✘ kaiocunha@Kaios-MacBook-Pro  ~  cd Desktop/projects/git/go/api-go-rest/migration/docker-database-initial.sql
cd: not a directory: Desktop/projects/git/go/api-go-rest/migration/docker-database-initial.sql
 ✘ kaiocunha@Kaios-MacBook-Pro  ~  cd Desktop/projects/git/go/api-go-rest/migration/                           
 kaiocunha@Kaios-MacBook-Pro  ~/Desktop/projects/git/go/api-go-rest/migration  ↱ master  chmod 775 -R Desktop/projects/git/go/api-go-rest/migration/docker-database-initial.sql
chmod: -R: No such file or directory
chmod: Desktop/projects/git/go/api-go-rest/migration/docker-database-initial.sql: No such file or directory
 ✘ kaiocunha@Kaios-MacBook-Pro  ~/Desktop/projects/git/go/api-go-rest/migration  ↱ master  chmod 775 -R Desktop/projects/git/go/api-go-rest/migration/                           
chmod: -R: No such file or directory
chmod: Desktop/projects/git/go/api-go-rest/migration/: No such file or directory
 ✘ kaiocunha@Kaios-MacBook-Pro  ~/Desktop/projects/git/go/api-go-rest/migration  ↱ master  pwd
/Users/kaiocunha/Desktop/projects/git/go/api-go-rest/migration
 kaiocunha@Kaios-MacBook-Pro  ~/Desktop/projects/git/go/api-go-rest/migration  ↱ master  chmod 775 -R $pwd   
chmod: -R: No such file or directory
 ✘ kaiocunha@Kaios-MacBook-Pro  ~/Desktop/projects/git/go/api-go-rest/migration  ↱ master  pwd
/Users/kaiocunha/Desktop/projects/git/go/api-go-rest/migration
 kaiocunha@Kaios-MacBook-Pro  ~/Desktop/projects/git/go/api-go-rest/migration  ↱ master  chmod 775 -R /Users/kaiocunha/Desktop/projects/git/go/api-go-rest/migration/docker-database-initial.sql 
chmod: -R: No such file or directory

Além disso, habilitei Full Disk Access para o meu terminal(MacOS) no menu de Security & Privacy.