[fpc-pascal] Database migration

Michael Van Canneyt michael at freepascal.org
Sun Jun 21 00:30:37 CEST 2020



On Sun, 21 Jun 2020, Jean SUZINEAU wrote:

> Hello,
> Le 19/06/2020 à 13:55, Darius Blaszyk via fpc-pascal a écrit :
>       Schema::create('flights', function (Blueprint $table) {
>
>             $table->id();
>             $table->string('name');
>             $table->string('airline');
>             $table->timestamps();
>         });
> 
> I have something that looks a bit like this, a kind of ORM (sorry, part of my identifiers are in French, "champ" means "field")
> 
> ... in the class declaration
>
>   //champs persistants
>   public
>     nUser: Integer;
>     nProject: Integer;
>     Beginning: TDateTime; cBeginning: TChamp;
>     End_     : TDateTime; cEnd      : TChamp;
>     Description: String;
> 
> ... in the implementation of the constructor :
>
>      Champs.ChampDefinitions.NomTable:= 'Work';
>
>      //champs persistants
>      Integer_from_ ( nUser          , 'nUser'          );
>      Integer_from_ ( nProject       , 'nProject'       );
>
>      cBeginning:= DateTime_from_( Beginning      , 'Beginning'      );
>      cBeginning.Definition.Format_DateTime:= 'yyyy/mm/dd" "hh:nn';
>
>      cEnd:= DateTime_from_( End_           , 'End'            );
>      cEnd.Definition.Format_DateTime:= 'yyyy/mm/dd" "hh:nn';
> 
> (this is extracted from class TblWork from
> https://github.com/jsuzineau/pascal_o_r_mapping/blob/master/jsWorks/Elements/Work/ublWork.pas )
> 
> This class is for a row of the table "Work", most of the time, the instance is initialized by reading a row of dataset, but I've
> started some code to read from some other source, like android database or JSON data.
> 
> I've made a source code generator which can query the structure of a database, and generate source codes from templates.
> Particularly it can create the skeleton of unit ublWork.pas which contains class TblWork

FPC contains this as well since many years, you can drop the components on a form, but they
are exposed in the lazarus database desktop as well.

Michael.


More information about the fpc-pascal mailing list