There is a program in PHP, but there is no database for it, the colleagues promised to dump the database dump, but it is unknown when this will happen ... Is there any way to tear the database structure out of the code? (talking about dozens of databases, each of which has dozens (hundreds) of tables)?

  • In the subd oracle there are service tables using which you can get information about the subd structure: tables, fields with types, indices, etc. etc. With the help of a not very complicated script, you can derive almost the entire structure of the subd I think these scripts can be found on the Internet, it is likely that for your subd - jmu

2 answers 2

Most likely, the entire circuit with the structure of the labels is sewn somewhere in the code. So usually do :)

Try searching in files by the words "create table"

  • and I don’t do that)))) in production, this is a crazy idea in general), provided that "usually" make a request in any case like "create table if not exists" this is very expensive for resources ... or a separate installer, but usually This is managed by a separate dbadmin group, which, when deployed, execute clean sql with db changes ... - thunder
  • The scheme is often included in the code for tests. Well, in order to version it, modify it instead of the code, check the compliance of the base and the scheme at the start, and so on :) It’s a pity that you don’t do that. - Andrew Frolov
  • no, these are not stitched, 100% ... (((repository from the gita ... - Andrei Talanin
  • Another option is to search if any ORM is used in the code. If yes, then you can force it to run the database schema based on the mapping :) If there are few SQL lines in the code, then ORM is probably there, and reverse engineering is possible. - Andrew Frolov
  • 2
    most likely to you here docs.doctrine-project.org/en/latest/reference/… - Andrew Frolov

In part, read the queries to the database and hope that all the fields of all the tables are involved in these queries :) Well, it will take a lot of time and sooooo much ... IMHO it's not worth it.

  • @thunder - I once set such a task, displayed all requests to the database and began to restore slowly, in 5 hours I managed. There were 20 tables. - Opalosolo
  • indices of all kinds IMHO only at random can be set ... and here dozens of dB and hundreds of tables in each ... - thunder