Skip to content

Commit

Permalink
Generating package for Release 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
lerocha committed Nov 15, 2010
1 parent 43a5e44 commit 4b8de61
Show file tree
Hide file tree
Showing 17 changed files with 116 additions and 47 deletions.
93 changes: 57 additions & 36 deletions ChinookDatabase/DataSources/ChinookDatabase.tt
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,24 @@ var fileManager = Manager.Create(Host, GenerationEnvironment);
foreach (IDdlStrategy strategy in options.DdlStrategies)
{
//************************************************************************
// Start SQL file.
// Start of SQL file.
//************************************************************************
var filename = GetFileName(strategy, strategy.ScriptFileExtension);
fileManager.StartNewFile(filename, strategy.Encoding);

var details = (strategy.IsIdentityEnabled ? "Primary keys are auto incremented." : "Primary keys are not auto incremented by the database system, they must be set when inserting records.");

// Add the script file to the package list.
options.OutputFiles.Add(new OutputFile { Name = filename, Package = strategy.Name });
options.OutputFiles.Add(new OutputFile { Name = filename, Package = strategy.Name, Description = "SQL script to create the Chinook database. " + details });

// If there is also a database file, then add it to the package list as well.
if (!string.IsNullOrEmpty(strategy.DatabaseFileExtension))
{
var dbfilename = GetFileName(strategy, strategy.DatabaseFileExtension);
options.OutputFiles.Add(new OutputFile { Name = dbfilename, Package = strategy.Name });
options.OutputFiles.Add(new OutputFile { Name = dbfilename, Package = strategy.Name, Description = "Chinook database file. " + details });
}

#>

/*******************************************************************************
Chinook Database - Version <#= options.Version #>
Script: <#= filename #>
Expand Down Expand Up @@ -295,24 +298,22 @@ CREATE INDEX <#= ifkName #> ON <#= toTableName #> (<#= strategy.GetColumns(const
<#

//************************************************************************
// End SQL file.
// End of SQL file.
//************************************************************************
fileManager.EndBlock();
} // foreach options.DdlStrategies


var strategies = (from item in options.DdlStrategies select new { item.Name, item.CommandLineFormat }).Distinct();
foreach (var strategy in strategies)
foreach (var strategy in options.DdlStrategies.Select(s=> new { s.Name, s.CommandLineFormat }).Distinct())
{
//************************************************************************
// Start batch file.
// Start of Create DB Batch file.
//************************************************************************
var filename = string.Format("Create{0}.bat", strategy.Name);
var commandFormat = "echo {0}";

if (!string.IsNullOrEmpty(strategy.CommandLineFormat))
{
options.OutputFiles.Add(new OutputFile { Name = filename, Package = strategy.Name });
options.OutputFiles.Add(new OutputFile { Name = filename, Package = strategy.Name, Description = "Batch file to create the Chinook database." });
fileManager.StartNewFile(filename, Encoding.ASCII);
#>
@echo off
Expand All @@ -334,19 +335,19 @@ goto END
echo Options:
echo.
<#
// Get all files of the same strategy.
IList<IDdlStrategy> items = (from item in options.DdlStrategies where item.Name == strategy.Name select item).ToList();
for(int i=0; i<items.Count; i++)
{
// Get all files of the same strategy.
IList<IDdlStrategy> items = options.DdlStrategies.Where(s=>s.Name==strategy.Name).ToList();
for(int i=0; i<items.Count; i++)
{
#>
echo <#= (i+1) #>. Run <#= GetFileName(items[i], items[i].ScriptFileExtension) #>
<# } #>
<# } #>
echo <#= items.Count+1 #>. Exit
echo.
choice /c 123
<# for(int i=0; i<items.Count; i++) { #>
<# for(int i=0; i<items.Count; i++) { #>
if (%ERRORLEVEL%)==(<#= (i+1) #>) set SQLFILE=<#= GetFileName(items[i],items[i].ScriptFileExtension) #>
<# } #>
<# } #>
if (%ERRORLEVEL%)==(<#= items.Count+1 #>) goto END

:RUNSQL
Expand All @@ -359,17 +360,15 @@ echo.
set SQLFILE=

<#
//************************************************************************
// End batch file.
//************************************************************************
//************************************************************************
// End of Create DB Batch file.
//************************************************************************
fileManager.EndBlock();
}
} // foreach options.DdlStrategies



//************************************************************************
// Start packaging file.
// Start of Package file.
//************************************************************************
fileManager.StartNewFile("Package.bat", Encoding.ASCII);
#>
Expand All @@ -381,39 +380,61 @@ if not exist %rootDir%\Packages mkdir %rootDir%\Packages

<#
var allfiles = options.OutputFiles.Select(o => o.Name);
var completePackageFile = string.Format("ChinookDatabase{0}_CompleteVersion.zip", options.Version);
#>
7z a %rootDir%\Packages\ChinookDatabase<#=options.Version#>_FullVersion.zip <#=GetValues(allfiles, ' ')#>
7z a %rootDir%\Packages\<#=completePackageFile#> <#=GetValues(allfiles, ' ')#> _Xml\ChinookData.xml
<#
var packages = from item in options.OutputFiles select item.Package;
foreach (var package in packages.Distinct())
foreach (var package in options.OutputFiles.Select(o=>o.Package).Distinct())
{
var files = from item in options.OutputFiles where item.Package == package select item.Name;
#>
7z a %rootDir%\Packages\ChinookDatabase<#=options.Version#>_<#=package#>.zip <#=GetValues(files, ' ')#>
<#
}
#>

<#
//************************************************************************
// End of packaging file.
// End of Package file.
//************************************************************************

fileManager.EndBlock();

fileManager.Process(true);
#>

// Add files that were not generated here, but will be part of the release.
options.OutputFiles.Add(new OutputFile { Name = "ChinookData.xml",
Package = "XML",
Description = "XML data used to generate the Chinook database SQL scripts." });#>
Chinook Database <#= options.Version #>
* This is a sample database available in multiple formats: SQL scripts for multiple database vendors, embeded database files, and XML format.
* The Chinook data model is available [here|Chinook_Schema].
* <#=completePackageFile#> is a complete package for all supported databases/data sources. There are also packages for each specific data source.
!! Supported Database Servers
* [url:EffiProz|http://effiproz.codeplex.com/]
* [url:MySQL|http://www.mysql.com/]
* [url:Oracle|http://www.oracle.com/technetwork/database/express-edition/overview/index.html]
* [url:SQL Server|http://www.microsoft.com/sqlserver/]
* [url:SQL Server Compact|http://www.microsoft.com/sqlserver/2008/en/us/compact.aspx]
* [url:SQLite|http://www.sqlite.org/]
!! Issues Resolved
* [workitem:29372]
* [workitem:29373]
!! Installation
* [How do I create the Chinook Database?|Create_Databases]
!! Package Content
This is the list of files included in the complete version.
|| Data Source || File || Description ||
<# foreach (var file in options.OutputFiles.OrderBy(o=>o.Package)) { #>
| <#= file.Package #> | {"<#= file.Name #>"} | <#= file.Description #> |
<# } #>
<#+

public class OutputFile {
public string Name { get; set; }
public string Package { get; set; }
public string Description { get; set; }
}

private static string GetFileName(IDdlStrategy strategy, string extension)
{
var suffix = string.Empty;
if (strategy.IsIdentityEnabled)
suffix = "_AutoIncrementPKs";

var suffix = (strategy.IsIdentityEnabled ? "_AutoIncrementPKs" : string.Empty);
return string.Format("Chinook_{0}{1}.{2}", strategy.Name, suffix, extension);
}

Expand Down
39 changes: 39 additions & 0 deletions ChinookDatabase/DataSources/ChinookDatabase.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,41 @@


Chinook Database 1.3
* This is a sample database available in multiple formats: SQL scripts for multiple database vendors, embeded database files, and XML format.
* The Chinook data model is available [here|Chinook_Schema].
* ChinookDatabase1.3_CompleteVersion.zip is a complete package for all supported databases/data sources. There are also packages for each specific data source.
!! Supported Database Servers
* [url:EffiProz|http://effiproz.codeplex.com/]
* [url:MySQL|http://www.mysql.com/]
* [url:Oracle|http://www.oracle.com/technetwork/database/express-edition/overview/index.html]
* [url:SQL Server|http://www.microsoft.com/sqlserver/]
* [url:SQL Server Compact|http://www.microsoft.com/sqlserver/2008/en/us/compact.aspx]
* [url:SQLite|http://www.sqlite.org/]
!! Issues Resolved
* [workitem:29372]
* [workitem:29373]
!! Installation
* [How do I create the Chinook Database?|Create_Databases]
!! Package Content
This is the list of files included in the complete version.
|| Data Source || File || Description ||
| EffiProz | {"Chinook_EffiProz.sql"} | SQL script to create the Chinook database. Primary keys are not auto incremented by the database system, they must be set when inserting records. |
| EffiProz | {"Chinook_EffiProz_AutoIncrementPKs.sql"} | SQL script to create the Chinook database. Primary keys are auto incremented. |
| MySql | {"Chinook_MySql.sql"} | SQL script to create the Chinook database. Primary keys are not auto incremented by the database system, they must be set when inserting records. |
| MySql | {"Chinook_MySql_AutoIncrementPKs.sql"} | SQL script to create the Chinook database. Primary keys are auto incremented. |
| MySql | {"CreateMySql.bat"} | Batch file to create the Chinook database. |
| Oracle | {"Chinook_Oracle.sql"} | SQL script to create the Chinook database. Primary keys are not auto incremented by the database system, they must be set when inserting records. |
| Oracle | {"CreateOracle.bat"} | Batch file to create the Chinook database. |
| Sqlite | {"Chinook_Sqlite.sql"} | SQL script to create the Chinook database. Primary keys are not auto incremented by the database system, they must be set when inserting records. |
| Sqlite | {"Chinook_Sqlite.sqlite"} | Chinook database file. Primary keys are not auto incremented by the database system, they must be set when inserting records. |
| Sqlite | {"Chinook_Sqlite_AutoIncrementPKs.sql"} | SQL script to create the Chinook database. Primary keys are auto incremented. |
| Sqlite | {"Chinook_Sqlite_AutoIncrementPKs.sqlite"} | Chinook database file. Primary keys are auto incremented. |
| Sqlite | {"CreateSqlite.bat"} | Batch file to create the Chinook database. |
| SqlServer | {"Chinook_SqlServer.sql"} | SQL script to create the Chinook database. Primary keys are not auto incremented by the database system, they must be set when inserting records. |
| SqlServer | {"Chinook_SqlServer_AutoIncrementPKs.sql"} | SQL script to create the Chinook database. Primary keys are auto incremented. |
| SqlServer | {"CreateSqlServer.bat"} | Batch file to create the Chinook database. |
| SqlServerCompact | {"Chinook_SqlServerCompact.sqlce"} | SQL script to create the Chinook database. Primary keys are not auto incremented by the database system, they must be set when inserting records. |
| SqlServerCompact | {"Chinook_SqlServerCompact.sdf"} | Chinook database file. Primary keys are not auto incremented by the database system, they must be set when inserting records. |
| SqlServerCompact | {"Chinook_SqlServerCompact_AutoIncrementPKs.sqlce"} | SQL script to create the Chinook database. Primary keys are auto incremented. |
| SqlServerCompact | {"Chinook_SqlServerCompact_AutoIncrementPKs.sdf"} | Chinook database file. Primary keys are auto incremented. |
| XML | {"ChinookData.xml"} | XML data used to generate the Chinook database SQL scripts. |
3 changes: 2 additions & 1 deletion ChinookDatabase/DataSources/Chinook_EffiProz.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*******************************************************************************

/*******************************************************************************
Chinook Database - Version 1.3
Script: Chinook_EffiProz.sql
Description: Creates and populates the Chinook database.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*******************************************************************************

/*******************************************************************************
Chinook Database - Version 1.3
Script: Chinook_EffiProz_AutoIncrementPKs.sql
Description: Creates and populates the Chinook database.
Expand Down
3 changes: 2 additions & 1 deletion ChinookDatabase/DataSources/Chinook_MySql.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*******************************************************************************

/*******************************************************************************
Chinook Database - Version 1.3
Script: Chinook_MySql.sql
Description: Creates and populates the Chinook database.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*******************************************************************************

/*******************************************************************************
Chinook Database - Version 1.3
Script: Chinook_MySql_AutoIncrementPKs.sql
Description: Creates and populates the Chinook database.
Expand Down
3 changes: 2 additions & 1 deletion ChinookDatabase/DataSources/Chinook_Oracle.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*******************************************************************************

/*******************************************************************************
Chinook Database - Version 1.3
Script: Chinook_Oracle.sql
Description: Creates and populates the Chinook database.
Expand Down
Binary file modified ChinookDatabase/DataSources/Chinook_SqlServer.sql
Binary file not shown.
Binary file modified ChinookDatabase/DataSources/Chinook_SqlServerCompact.sdf
Binary file not shown.
3 changes: 2 additions & 1 deletion ChinookDatabase/DataSources/Chinook_SqlServerCompact.sqlce
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*******************************************************************************

/*******************************************************************************
Chinook Database - Version 1.3
Script: Chinook_SqlServerCompact.sqlce
Description: Creates and populates the Chinook database.
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*******************************************************************************

/*******************************************************************************
Chinook Database - Version 1.3
Script: Chinook_SqlServerCompact_AutoIncrementPKs.sqlce
Description: Creates and populates the Chinook database.
Expand Down
Binary file not shown.
3 changes: 2 additions & 1 deletion ChinookDatabase/DataSources/Chinook_Sqlite.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*******************************************************************************

/*******************************************************************************
Chinook Database - Version 1.3
Script: Chinook_Sqlite.sql
Description: Creates and populates the Chinook database.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*******************************************************************************

/*******************************************************************************
Chinook Database - Version 1.3
Script: Chinook_Sqlite_AutoIncrementPKs.sql
Description: Creates and populates the Chinook database.
Expand Down
3 changes: 1 addition & 2 deletions ChinookDatabase/DataSources/Package.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ if (%rootDir%)==() set rootDir=%cd%
if exist %rootDir%\Packages\. del %rootDir%\Packages\*.* /q
if not exist %rootDir%\Packages mkdir %rootDir%\Packages

7z a %rootDir%\Packages\ChinookDatabase1.3_FullVersion.zip Chinook_SqlServer.sql Chinook_SqlServer_AutoIncrementPKs.sql Chinook_SqlServerCompact.sqlce Chinook_SqlServerCompact.sdf Chinook_SqlServerCompact_AutoIncrementPKs.sqlce Chinook_SqlServerCompact_AutoIncrementPKs.sdf Chinook_Sqlite.sql Chinook_Sqlite.sqlite Chinook_Sqlite_AutoIncrementPKs.sql Chinook_Sqlite_AutoIncrementPKs.sqlite Chinook_MySql.sql Chinook_MySql_AutoIncrementPKs.sql Chinook_Oracle.sql Chinook_EffiProz.sql Chinook_EffiProz_AutoIncrementPKs.sql CreateSqlServer.bat CreateSqlite.bat CreateMySql.bat CreateOracle.bat
7z a %rootDir%\Packages\ChinookDatabase1.3_CompleteVersion.zip Chinook_SqlServer.sql Chinook_SqlServer_AutoIncrementPKs.sql Chinook_SqlServerCompact.sqlce Chinook_SqlServerCompact.sdf Chinook_SqlServerCompact_AutoIncrementPKs.sqlce Chinook_SqlServerCompact_AutoIncrementPKs.sdf Chinook_Sqlite.sql Chinook_Sqlite.sqlite Chinook_Sqlite_AutoIncrementPKs.sql Chinook_Sqlite_AutoIncrementPKs.sqlite Chinook_MySql.sql Chinook_MySql_AutoIncrementPKs.sql Chinook_Oracle.sql Chinook_EffiProz.sql Chinook_EffiProz_AutoIncrementPKs.sql CreateSqlServer.bat CreateSqlite.bat CreateMySql.bat CreateOracle.bat _Xml\ChinookData.xml
7z a %rootDir%\Packages\ChinookDatabase1.3_SqlServer.zip Chinook_SqlServer.sql Chinook_SqlServer_AutoIncrementPKs.sql CreateSqlServer.bat
7z a %rootDir%\Packages\ChinookDatabase1.3_SqlServerCompact.zip Chinook_SqlServerCompact.sqlce Chinook_SqlServerCompact.sdf Chinook_SqlServerCompact_AutoIncrementPKs.sqlce Chinook_SqlServerCompact_AutoIncrementPKs.sdf
7z a %rootDir%\Packages\ChinookDatabase1.3_Sqlite.zip Chinook_Sqlite.sql Chinook_Sqlite.sqlite Chinook_Sqlite_AutoIncrementPKs.sql Chinook_Sqlite_AutoIncrementPKs.sqlite CreateSqlite.bat
7z a %rootDir%\Packages\ChinookDatabase1.3_MySql.zip Chinook_MySql.sql Chinook_MySql_AutoIncrementPKs.sql CreateMySql.bat
7z a %rootDir%\Packages\ChinookDatabase1.3_Oracle.zip Chinook_Oracle.sql CreateOracle.bat
7z a %rootDir%\Packages\ChinookDatabase1.3_EffiProz.zip Chinook_EffiProz.sql Chinook_EffiProz_AutoIncrementPKs.sql

1 change: 1 addition & 0 deletions ChinookDatabase/DataSources/createall.bat
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ rem echo Chinook_SqlServerCompact.sql
rem sqlcecmd �d "Data Source=.\Chinook_SqlServerCompact.sdf" �e create
rem echo.

:end

0 comments on commit 4b8de61

Please sign in to comment.