Les pieds dans le code

Pour apprendre à programmer, le mieux est de metre les pieds dedans.

auteure : Daniela

Participants :

Nastassja, Daniela, Etienne, Laurent,

Activités

1. Révision de la racine «/»

2. Discussion sur un problème de déploiement en conséquence de 7 migrations orphelines dans une app rails 5.2.

Comment le problème s’est produit :

StandardError: An error has occurred, this and all later migrations canceled:

PG::UndefinedTable: ERROR: table “csp_reports” does not exist

DROP TABLE « csp_reports” ```

➜ git:(master) rails db:migrate:status

 database: development
 Status Migration ID Migration Name

--------------------------------------------------

up 20190829145132 ********** NO FILE **********

up 20190829145133 ********** NO FILE **********

up 20190829145134 ********** NO FILE **********

up 20190829145135 ********** NO FILE **********

up 20190829145136 ********** NO FILE **********

up 20190829145137 ********** NO FILE **********

up 20191023125058 ********** NO FILE **********

Solution :

1er essai : Doc Rails 5.2

➜ git:(master) heroku pg:reset DATABASE_URL

➜ git:(master) heroku run rails db:migrate
rails aborted!

StandardError: An error has occurred, this and all later migrations canceled:

PG::UndefinedTable: ERROR: table "csp_reports" does not exist

2e essai : Doc d’une source 2014 : https://jacopretorius.net/2014/02/all-rails-db-rake-tasks-and-what-they-do.html

➜ git:(master) heroku run rails db:schema:load
rails aborted!

ActiveRecord::NoEnvironmentInSchemaError:

Environment data not found in the schema. To resolve this issue, run:

bin/rails db:environment:set RAILS_ENV=production

3e essai : Doc Rails 5.2

➜ git:(master) heroku run rails db:create
Running rails db:create on ⬢ absourcing-beta1... up, run.7153 (Hobby)

FATAL: permission denied for database "postgres"

DETAIL: User does not have CONNECT privilege.

4e essai : Doc d’une source 2014: https://jacopretorius.net/2014/02/all-rails-db-rake-tasks-and-what-they-do.html

➜ git:(master) heroku run rails db:drop:all
rails aborted!

ActiveRecord::NoEnvironmentInSchemaError:

Environment data not found in the schema. To resolve this issue, run:

bin/rails db:environment:set RAILS_ENV=production

5e essai : Instructions rails (terminal)

➜ `git:(master) heroku run rails db:environment:set RAILS_ENV=production`

rails aborted!

ActiveRecord::ProtectedEnvironmentError: You are attempting to run a destructive action against your 'production' database.
If you are sure you want to continue, run the same command with the environment variable:
DISABLE_DATABASE_ENVIRONMENT_CHECK=1
➜ git:(master) heroku run rails db:schema:load DISABLE_DATABASE_ENVIRONMENT_CHECK=1

➜ git:(master) heroku run rails db:migrate

➜ git:(master) heroku run rails db:seed

Problème résolu !

Problème non résolu, mais moins urgent : local incohérent, les 7 migrations restent orphelines.