Task: Implement the CreateTableGenerator Functionality
Functionality Description:
Implement the CreateTableGenerator class that extends AbstractSqlGenerator<CreateTableStatement>. This class is responsible for generating SQL statements for creating database tables based on a provided CreateTableStatement object. The implementation must handle various constraints (primary key, foreign key, unique constraints, etc.) and adapt to different database types (SQLite, MSSQL, MySQL, etc.).
Input Requirements:
CreateTableStatement statement: An object that contains the details of the table to be created, including:
Schema name
Table name
List of columns and their types
Primary key constraints
Unique constraints
Foreign key constraints
Auto-increment constraints
Default values for columns
Not-null column specifications
Tablespace for the table (if applicable)
Database database: An object representing the database type, which provides methods for escaping table and column names, and generating SQL specific to the database type.
SqlGeneratorChain sqlGeneratorChain: An object used for generating SQL in a chain of SQL generators.
Output Requirements:
The method generateSql should return an array of Sql objects, specifically an instance of UnparsedSql containing the generated SQL statement for creating the table.
Actionable Steps:
Implement the CreateTableGenerator class in the /app/ directory.
Define the generateSql method as specified in the function signature, ensuring it constructs the SQL create table statement according to the input CreateTableStatement.
Handle various constraints and database-specific requirements as outlined in the provided code.
Ensure that all generated SQL statements are properly formatted and valid for the specific database type.
Write unit tests to validate the correct generation of SQL for different scenarios and database types.