SMEWebify / WebErpMesv2

Ressource Management and Manufacturing execution system Web for industry (sheet metal, machining, mold ...)
http://demo.wem-project.org/
MIT License
133 stars 71 forks source link

Tables conventions #15

Closed RobertoBochet closed 2 years ago

RobertoBochet commented 2 years ago

Is your feature request related to a problem? Please describe.

When I was developing some seeders for the database I noticed that it seems there is not a real convention in table columns names: Some name in English, some in French, some uppercase, some snake_case.

I think this standardization in future can improve the maintainability of the code.

Additional for example, for a not french person it is really difficult to deal with French names.

Describe the solution you'd like

Laravel for its tables (like users) use the snake_case in English, maybe it may be used for all tables.

This is only a proposal

SMEWebify commented 2 years ago

Hi @RobertoBochet ,

you are right, this is explained by the fact that the first version was French and that I used utilities to convert the existing database into a migration file.

But I knew I was gonna have to do this job, I had never done this work, because I did not know how to treat these subjects

Example : Shouldn't code be external id? shouldn't label be description? Order/order shouldn't be sort number?

In priority, what are the words in French that you do not understand? (I think mainly on the companies table) Then I'll put it all in lowercase

SMEWebify commented 2 years ago

changing fields to lowercase affects 155 files

After change, i have an error :

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'statu_customer' in 'where clause' (SQL: select count(*) as aggregate from companies where statu_customer = 2)

it's because the docker base is not updated with the artisan migrate refresh command I guess

Hox make migration update on instance of mariadb ?

SMEWebify commented 2 years ago

improvement proposal for the company table mainly

Schema::create('companies', function (Blueprint $table) {
            $table->id();
            $table->string('CODE');
            $table->string('LABEL');
            $table->string('website')->nullable();
            $table->string('fbsite')->nullable();
            $table->string('twittersite')->nullable();
            $table->string('lkdsite')->nullable();
            $table->string('SIREN')->nullable();
            $table->string('naf_code')->nullable();
            $table->string('intra_community_vat')->nullable();
            $table->string('picture')->nullable();
            $table->integer('statu_customer')->default(0);
            $table->integer('discount')->nullable()->default(0);
            $table->integer('user_id')->nullable()->default(0);
            $table->integer('account_general_customer')->nullable()->default(0);
            $table->integer('account_auxiliary_customer')->nullable()->default(0);
            $table->integer('statu_supplier')->default(0);
            $table->integer('account_general_supplier')->nullable()->default(0);
            $table->integer('account_auxiliary_supplier')->nullable()->default(0);
            $table->integer('recept_controle')->default(0);
            $table->text('comment', 65535)->nullable();
            $table->string('sector_id')->nullable();
            $table->timestamps();

        });

SIREN = DUNS number but I'm not sure

SMEWebify commented 2 years ago

@RobertoBochet I put all table columns in lower case and replace French terms.

I close the issue, if necessary do not hesitate to bring other changes

SMEWebify commented 2 years ago

@RobertoBochet I also launched some seeder via factories, don't hesitate to pull, I'll try to merge the work

I commented DatabaseSeeder.php, depending on the relationships, the seeders must respect an order.