Blog
All Blog Posts | Next Post | Previous PostMy Top 10 Aurelius Features - #7 Schema Update
Tuesday, January 3, 2017
When creating a database-based application, one of the tasks I always considered boring was to create the database structure, table, fields, foreign keys. Even using a tool to generate a SQL would require me to create a table, add columns, column types, foreign keys, etc.That's why I consider the ability to automatically create and update the database schema to be the #7 feature of My Top 10 Aurelius Features. It's simply something I don't need to care about anymore.
Updating the database is as easy as doing this:
TDatabaseManager.Update(Connection);
Note that I'm talking about updating, not creating the database. That makes application prototyping and development really fast. Create the database, change your application, add a new table, update the database, and it goes on.
Even though updating the database is as simple as using one line of code, Aurelius provides advanced features for the database update process, like validation. With a code like the following, you can check the differences between the schema of the existing database, and what is needed in the schema to hold the current entity model you have. It shows you the differences without requiring you to actually execute the SQL statements:
procedure TForm1.ValidateMyDatabaseSchema; var DBManager: TDatabaseManager; Action: TSchemaAction; Warning: TSchemaWarning; Error: TSchemaError; begin DBManager := TDatabaseManager.Create(Connection); try DBManager.ValidateDatabase; { Show SQL statements } mmStatements.Clear; for Statement in DBManager.SQLStatements do begin mmStatements.Lines.Add(Statement); mmStatements.Lines.Add(''); end; { Show validation results } mmValidation.Clear; mmValidation.Lines.Add('----- Actions -----'); for Action in DBManager.Actions do mmValidation.Lines.Add(Format('%s -> %s', [Action.ClassName, Action.Text])); mmValidation.Lines.Add(''); mmValidation.Lines.Add('----- Warnings -----'); for Warning in DBManager.Warnings do mmValidation.Lines.Add(Format('%s: %s', [Warning.ClassName, Warning.Text])); mmValidation.Lines.Add(''); mmValidation.Lines.Add('----- Errors -----'); for Error in DBManager.Errors do mmValidation.Lines.Add(Format('%s: %s', [Error.ClassName, Error.Text])); finally DBManager.Free; end; end;
Wagner Landgraf
This blog post has received 2 comments.
2. Monday, January 9, 2017 at 11:38:23 AM
Hi Neal, thank you for the compliments. If you mean the source code of projects used in the series, problem is that there isn''t much, most is just code snippets and use of tools. But please contact us directly through e-mail if you need more info about a specific video.
Wagner R. Landgraf
All Blog Posts | Next Post | Previous Post
This is an absolutely great series, exactly what is needed to get started productively with Aurelius! Thank you!
Neal Campbell