Class SchemaBuilder
java.lang.Object
com.valqueries.automapper.context.schema.SchemaBuilder
- All Implemented Interfaces:
ISchemaBuilder
,AutoCloseable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAlter an existing table.alterIfExists
(Token table) Alter an existing table if it exists.void
close()
boolean
columnExists
(Token table, Token column) Check if a column exists.Create a new table.void
createDatabaseAndUser
(String databaseName, String username, String password) Creates a new database and user.createIfNotExists
(Token table) Create a new table if it does not already exist.void
Drop an existing table.void
dropIfExists
(Token table) Drop an existing table if it exists.boolean
Check if a table exists.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.valqueries.automapper.context.schema.ISchemaBuilder
alter, alterIfExists, columnExists, create, createIfNotExists, drop, dropIfExists, exists
-
Constructor Details
-
SchemaBuilder
-
-
Method Details
-
create
Description copied from interface:ISchemaBuilder
Create a new table. Will fail if a table with the same name already exists.Note: remember to call
IBaseBuilder.execute()
- Specified by:
create
in interfaceISchemaBuilder
- Parameters:
table
- that will be created.- Returns:
- a builder that can be used to build the new table.
-
createIfNotExists
Description copied from interface:ISchemaBuilder
Create a new table if it does not already exist. Does nothing if a table with the same name already exists, no matter its contents.Note: remember to call
IBaseBuilder.execute()
- Specified by:
createIfNotExists
in interfaceISchemaBuilder
- Parameters:
table
- that will be created if not already.- Returns:
- a builder that can be used to build the new table.
-
alter
Description copied from interface:ISchemaBuilder
Alter an existing table.Note: remember to call
IBaseBuilder.execute()
- Specified by:
alter
in interfaceISchemaBuilder
- Parameters:
table
- that will be altered.- Returns:
- a builder that can be used to alter the table.
-
alterIfExists
Description copied from interface:ISchemaBuilder
Alter an existing table if it exists.Note: remember to call
IBaseBuilder.execute()
- Specified by:
alterIfExists
in interfaceISchemaBuilder
- Parameters:
table
- that will be altered if it exists.- Returns:
- a builder that can be used to alter the table.
-
drop
Description copied from interface:ISchemaBuilder
Drop an existing table.- Specified by:
drop
in interfaceISchemaBuilder
- Parameters:
table
- that will be dropped.
-
dropIfExists
Description copied from interface:ISchemaBuilder
Drop an existing table if it exists.- Specified by:
dropIfExists
in interfaceISchemaBuilder
- Parameters:
table
- that will be dropped.
-
exists
Description copied from interface:ISchemaBuilder
Check if a table exists.- Specified by:
exists
in interfaceISchemaBuilder
- Parameters:
table
- to be checked- Returns:
- true if the table exists, false otherwise
-
columnExists
Description copied from interface:ISchemaBuilder
Check if a column exists.- Specified by:
columnExists
in interfaceISchemaBuilder
- Parameters:
table
- the table to check incolumn
- the column to be checked- Returns:
- true if the column exists, false otherwise
-
createDatabaseAndUser
Description copied from interface:ISchemaBuilder
Creates a new database and user. The user will be granted all privileges on the database.- Specified by:
createDatabaseAndUser
in interfaceISchemaBuilder
- Parameters:
databaseName
- The name of the database to createusername
- The name of the user to createpassword
- The password of the user to create
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceISchemaBuilder
-