ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/iblocaldb/nongui/IBCMLocalDBSupport.pas
(Generate patch)

Comparing ibx/trunk/iblocaldb/nongui/IBCMLocalDBSupport.pas (file contents):
Revision 272 by tony, Mon Feb 4 13:34:37 2019 UTC vs.
Revision 345 by tony, Mon Aug 23 14:22:29 2021 UTC

# Line 41 | Line 41 | type
41    private
42      FOnLogMessage: TOnLogMessage;
43      FOnProgressEvent: TOnProgressEvent;
44 <    procedure Add2Log(Sender: TObject; Msg: string);
45 <    procedure DoUpgrade(IBXScript: TIBXScript; TargetVersionNo: integer);
44 >    function DoUpgrade(IBXScript: TIBXScript; TargetVersionNo: integer): boolean;
45      procedure WriteLog(Msg: string);
46      procedure HandleOnGetNextLine(Sender: TObject; var Line: string);
47      procedure IBXScriptCreateDatabase(Sender: TObject;
48        var DatabaseFileName: string);
49    protected
50 +    procedure Add2Log(Sender: TObject; Msg: string); override;
51      procedure Downgrade(DBArchive: string); override;
52      function InternalCreateNewDatabase(DBArchive: string): boolean; override;
53      function RestoreDatabaseFromArchive(aFilename: string): boolean; override;
# Line 75 | Line 75 | begin
75    WriteLog(Msg);
76   end;
77  
78 < procedure TIBCMLocalDBSupport.DoUpgrade(IBXScript: TIBXScript;
79 <  TargetVersionNo: integer);
78 > function TIBCMLocalDBSupport.DoUpgrade(IBXScript: TIBXScript;
79 >  TargetVersionNo: integer): boolean;
80   var UpdateAvailable: boolean;
81      UpgradeInfo: TUpgradeInfo;
82      DBArchive: string;
# Line 85 | Line 85 | begin
85    repeat
86      if CurrentDBVersionNo >= TargetVersionNo then break;
87      LastVersionNo := CurrentDBVersionNo;
88 <    UpdateAvailable := UpgradeConf.GetUpgradeInfo(CurrentDBVersionNo+1,UpgradeInfo);
88 >    UpdateAvailable := UpgradeConf.GetUpgradeInfo(SectionHeaderTemplate,CurrentDBVersionNo+1,UpgradeInfo);
89      if UpdateAvailable then
90      begin
91        if UpgradeInfo.BackupDB then
# Line 96 | Line 96 | begin
96        end;
97        Add2Log(self,UpgradeInfo.UserMessage);
98        Add2Log(self,Format(sUpdateMsg,[UpgradeInfo.UpdateSQLFile]));
99 <      if not IBXScript.RunScript(UpgradeInfo.UpdateSQLFile) then
99 >      Result := IBXScript.RunScript(UpgradeInfo.UpdateSQLFile);
100 >      if not Result then
101         break;
102        UpdateVersionNo;
103      end;
# Line 125 | Line 126 | end;
126  
127   procedure TIBCMLocalDBSupport.Downgrade(DBArchive: string);
128   begin
129 +  inherited;
130    RestoreDatabase(DBArchive);
131 +  DowngradeDone;
132   end;
133  
134   function TIBCMLocalDBSupport.InternalCreateNewDatabase(DBArchive: string
# Line 170 | Line 173 | begin
173    begin
174      BackupFiles.Clear;
175      BackupFiles.Add(aFilename);
176 +    DatabaseFiles.Clear;
177 +    DatabaseFiles.Add(Database.DatabaseName);
178      Options := [Replace];
179      Execute(nil);
180    end;
# Line 179 | Line 184 | function TIBCMLocalDBSupport.RunUpgradeD
184    ): boolean;
185   var IBXScript: TIBXScript;
186   begin
182  Result := true;
187    IBXScript := TIBXScript.Create(self);
188    try
189      IBXScript.Database := Database;
# Line 187 | Line 191 | begin
191      IBXScript.OnOutputLog := @Add2Log;
192      if assigned(UpgradeConf) then
193        IBXScript.GetParamValue := @UpgradeConf.GetParamValue;
194 <    DoUpgrade(IBXScript, TargetVersionNo);
194 >    Result := DoUpgrade(IBXScript, TargetVersionNo);
195    finally
196      IBXScript.Free;
197    end;
# Line 195 | Line 199 | begin
199   end;
200  
201   function TIBCMLocalDBSupport.SaveDatabaseToArchive(aFilename: string): boolean;
198 var Service: TIBXClientSideBackupService;
202   begin
203    Result := true;
204    with BackupService do
205    begin
206 +    DatabaseName := Database.DatabaseName;
207 +    BackupFiles.Clear;
208 +    BackupFiles.Add(aFileName);
209      Execute(nil);
210      WriteLog(Format(sBackupDone,[aFileName]));
211    end;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines