#1 2016-08-10 08:44:00

lele9
Member
Registered: 2011-10-28
Posts: 170

modify record structure on database in production

hi,
i need to add a new field to a record that is declared in a TSQLRecord as array of record and stored as BLOB.

TImmobile = record
   Descrizione: RawUTF8;
   DatiCatastali: TIDDynArray;
   Percorrenza: Integer;
   Varia: Integer;                                <------------------------ NEW FIELD
end;
TImmobili = array of TImmobile;

TSQLConsorzio = class (TSQLRecord)
...
   property Immobili: TImmobili read FImmobili write FImmobili;
...
end;

If i insert new TSQLConsorzio it'all ok but when i try to retrieve an "old" TSQLConsorzio i have AV on retrieve.
The database is in production.
How can modify the structure and update the old blob field?
Thanks

Offline

#2 2016-08-10 09:49:29

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: modify record structure on database in production

What you did wouldn't work.

I think you should do it this way:
- Do not change the definition of TImmobile  and Immobili.
- Add a new type TImmobileNew with the new 'Varia' field added.
- Add a new property ImmobiliNew of type TImmobileNew.
- Migrate the data from 'Immobili' to 'ImmobiliNew'.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#3 2016-08-11 06:48:33

lele9
Member
Registered: 2011-10-28
Posts: 170

Re: modify record structure on database in production

thanks for the reply edwinsn!
for future implementation it might be best to avoid array of record to avoid such situations?in favor of?
thanks a lot!
Emanuele

Offline

Board footer

Powered by FluxBB