Skip to content

Commit

Permalink
changed autoSchemaCreate connection option to autoSchemaSync
Browse files Browse the repository at this point in the history
  • Loading branch information
Umed Khudoiberdiev committed Sep 20, 2016
1 parent 12b3f32 commit 5dc655e
Show file tree
Hide file tree
Showing 41 changed files with 63 additions and 63 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const options: CreateConnectionOptions = {
username: "root", // mysql database username
password: "admin", // mysql database password
database: "test", // mysql database name
autoSchemaCreate: true // if set to true, then database schema will be automatically created on each application start
autoSchemaSync: true // if set to true, then database schema will be automatically created on each application start
},
entities: [Photo] // array of classes you want to create tables for (and work with them in the current connection)
};
Expand Down
6 changes: 3 additions & 3 deletions docs/connection-and-connection-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export interface ConnectionOptions {
username?: string; // database username
password?: string; // database password
database?: string; // database name
autoSchemaCreate?: boolean; // set to true if you want your database schema to be auto created on each application launch
autoSchemaSync?: boolean; // set to true if you want your database schema to be auto created on each application launch
logging?: {

logger?: (message: any, level: string) => void; // some specific logger to be used. By default it is a console
Expand All @@ -83,7 +83,7 @@ export interface ConnectionOptions {
```

* To perform a connection you either must specify a connection `url`, either specify `host/port/username/password/database`.
* `autoSchemaCreate` allows you to automatically synchronize your database schema (create new tables,
* `autoSchemaSync` allows you to automatically synchronize your database schema (create new tables,
remove/rename old columns, create foreign keys, etc.) on each application run. Note that there can be errors in schema
synchronization (mostly errors can be caused by unresolved foreign keys) and this will crash your application.
This option should not be used in production, only during development and only if you are too lazy to use
Expand All @@ -103,7 +103,7 @@ let connectionOptions: ConnectionOptions = {
username: "root",
password: "admin",
database: "test",
autoSchemaCreate: true
autoSchemaSync: true
};

// create a new connection with mysql driver
Expand Down
2 changes: 1 addition & 1 deletion docs/updating-database-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Your database schema is managed automatically by ORM:

All this must be in sync to make ORM to work correctly. To make a synchronization there are two ways:

* set in [connection options](connection-and-connection-options.md#connection-options) `autoSchemaCreate: true`.
* set in [connection options](connection-and-connection-options.md#connection-options) `autoSchemaSync: true`.
In this case database schema will be automatically synchronized each time you run the application.

* use [schema update gulp plugin](todo) and run schema synchronization process each time you need it.
Expand Down
2 changes: 1 addition & 1 deletion ormconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"password": "admin",
"database": "test"
},
"autoSchemaCreate": true
"autoSchemaSync": true
}
]
4 changes: 2 additions & 2 deletions sample/sample1-simple-entity/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const options: ConnectionOptions = {
logQueries: true,
logSchemaCreation: true
},
autoSchemaCreate: false,
autoSchemaSync: false,
entities: [Post]
};
/*const options: CreateConnectionOptions = {
Expand All @@ -40,7 +40,7 @@ const options: ConnectionOptions = {
username: "test",
password: "admin",
database: "test",
autoSchemaCreate: true,
autoSchemaSync: true,
logging: {
logQueries: true
}
Expand Down
2 changes: 1 addition & 1 deletion sample/sample10-mixed/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const options: ConnectionOptions = {
password: "admin",
database: "test"
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [__dirname + "/entity/*"]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample11-all-types-entity/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const options: ConnectionOptions = {
logging: {
logOnlyFailedQueries: true
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [EverythingEntity]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample12-custom-naming-strategy/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const options: ConnectionOptions = {
password: "admin",
database: "test"
},
autoSchemaCreate: true,
autoSchemaSync: true,
usedNamingStrategy: "custom_strategy",
entities: [Post],
namingStrategies: [CustomNamingStrategy]
Expand Down
2 changes: 1 addition & 1 deletion sample/sample13-everywhere-abstraction/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const options: ConnectionOptions = {
logOnlyFailedQueries: true,
logFailedQueryError: true
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [__dirname + "/entity/*"]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample14-errors-in-wrong-metdata/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const options: ConnectionOptions = {
password: "admin",
database: "test"
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [Post, PostAuthor]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample16-indexes/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const options: ConnectionOptions = {
logOnlyFailedQueries: true,
logSchemaCreation: true
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [Post]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample17-versioning/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const options: ConnectionOptions = {
logOnlyFailedQueries: true,
logFailedQueryError: true
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [Post]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample18-lazy-relations/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const options: ConnectionOptions = {
logOnlyFailedQueries: true,
logFailedQueryError: true
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [Post, Author, Category]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample19-one-side-relations/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const options: ConnectionOptions = {
logOnlyFailedQueries: true,
logFailedQueryError: true
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [Post, Author, Category, PostMetadata]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample2-one-to-one/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const options: ConnectionOptions = {
logging: {
// logQueries: true
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [Post, PostDetails, PostCategory, PostMetadata, PostImage, PostInformation, PostAuthor]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample20-join-without-relation/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const options: ConnectionOptions = {
logOnlyFailedQueries: true,
logFailedQueryError: true
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [Post, Author, Category]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample21-custom-join-table-column/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const options: ConnectionOptions = {
logOnlyFailedQueries: true,
logFailedQueryError: true
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [Post, Author, Category]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample22-closure-table/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const options: ConnectionOptions = {
logOnlyFailedQueries: true,
logFailedQueryError: true
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [Category]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample23-nested-joins/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const options: ConnectionOptions = {
logOnlyFailedQueries: true,
logFailedQueryError: true
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [Post, Author, Category]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample24-schemas/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const options: ConnectionOptions = {
password: "admin",
database: "test"
},
autoSchemaCreate: true,
autoSchemaSync: true,
// entitySchemaDirectories: [__dirname + "/schemas"],
entitySchemas: [
require(__dirname + "/../../../../sample/sample24-schemas/schemas/post.json"),
Expand Down
2 changes: 1 addition & 1 deletion sample/sample25-insert-from-inverse-side/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const options: ConnectionOptions = {
logOnlyFailedQueries: true,
logFailedQueryError: true
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [Post, Author]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample26-embedded-tables/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const options: ConnectionOptions = {
logOnlyFailedQueries: true,
logFailedQueryError: true
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [Post, Question, Counters]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample27-composite-primary-keys/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const options: ConnectionOptions = {
logOnlyFailedQueries: true,
logFailedQueryError: true
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [Post]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample28-single-table-inheritance/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const options: ConnectionOptions = {
logOnlyFailedQueries: true,
logFailedQueryError: true
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [
Person,
Employee,
Expand Down
2 changes: 1 addition & 1 deletion sample/sample29-class-table-inheritance/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const options: ConnectionOptions = {
logOnlyFailedQueries: true,
logFailedQueryError: true
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [
Person,
Employee,
Expand Down
2 changes: 1 addition & 1 deletion sample/sample3-many-to-one/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const options: ConnectionOptions = {
password: "admin12345",
database: "test",
},
autoSchemaCreate: true,
autoSchemaSync: true,
logging: {
// logQueries: true,
logFailedQueryError: true
Expand Down
2 changes: 1 addition & 1 deletion sample/sample30-default-order-by/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const options: ConnectionOptions = {
logQueries: true,
logSchemaCreation: true
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [Post, Category]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample31-table-prefix/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const options: ConnectionOptions = {
storage: "temp/sqlitedb.db",
tablesPrefix: "samples_" // pay attention on this prefix
},
autoSchemaCreate: true,
autoSchemaSync: true,
logging: {
logQueries: true,
logSchemaCreation: true,
Expand Down
2 changes: 1 addition & 1 deletion sample/sample4-many-to-many/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const options: ConnectionOptions = {
logFailedQueryError: true,
// logQueries: true
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [__dirname + "/entity/*"]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample5-subscribers/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const options: ConnectionOptions = {
password: "admin",
database: "test"
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [Post, PostAuthor, PostCategory],
subscribers: [EverythingSubscriber]
};
Expand Down
2 changes: 1 addition & 1 deletion sample/sample6-abstract-table/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const options: ConnectionOptions = {
password: "admin",
database: "test"
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [__dirname + "/entity/*"]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample7-pagination/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const options: ConnectionOptions = {
password: "admin",
database: "test"
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [__dirname + "/entity/*"]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample8-self-referencing/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const options: ConnectionOptions = {
password: "admin",
database: "test"
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [__dirname + "/entity/*"]
};

Expand Down
2 changes: 1 addition & 1 deletion sample/sample9-entity-listeners/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const options: ConnectionOptions = {
password: "admin",
database: "test"
},
autoSchemaCreate: true,
autoSchemaSync: true,
entities: [__dirname + "/entity/*"],
subscribers: [__dirname + "/subscriber/*"]
};
Expand Down
10 changes: 5 additions & 5 deletions src/connection/ConnectionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class ConnectionManager {
/**
* Creates a new connection based on the given connection options and registers it in the manager.
* You need to manually call #connect method to establish connection.
* Note that dropSchemaOnConnection and autoSchemaCreate options of a ConnectionOptions will not work there - use
* Note that dropSchemaOnConnection and autoSchemaSync options of a ConnectionOptions will not work there - use
* createAndConnect method to use them.
*/
create(options: ConnectionOptions): Connection {
Expand Down Expand Up @@ -128,7 +128,7 @@ export class ConnectionManager {
* - TYPEORM_STORAGE - database's storage url. Used only for sqlite databases. Should be a string.
* - TYPEORM_USE_POOL - indicates if connection pooling should be enabled. By default its enabled. Should be boolean-like value.
* - TYPEORM_DRIVER_EXTRA - extra options to be passed to the driver. Should be a serialized json string of options.
* - TYPEORM_AUTO_SCHEMA_CREATE - indicates if automatic schema synchronization will be performed on each application run. Should be boolean-like value.
* - TYPEORM_AUTO_SCHEMA_SYNC - indicates if automatic schema synchronization will be performed on each application run. Should be boolean-like value.
* - TYPEORM_ENTITIES - list of directories containing entities to load. Should be string - directory names (can be patterns) split by a comma.
* - TYPEORM_SUBSCRIBERS - list of directories containing subscribers to load. Should be string - directory names (can be patterns) split by a comma.
* - TYPEORM_ENTITY_SCHEMAS - list of directories containing entity schemas to load. Should be string - directory names (can be patterns) split by a comma.
Expand Down Expand Up @@ -196,7 +196,7 @@ export class ConnectionManager {
* - TYPEORM_STORAGE - database's storage url. Used only for sqlite databases. Should be a string.
* - TYPEORM_USE_POOL - indicates if connection pooling should be enabled. By default its enabled. Should be boolean-like value.
* - TYPEORM_DRIVER_EXTRA - extra options to be passed to the driver. Should be a serialized json string of options.
* - TYPEORM_AUTO_SCHEMA_CREATE - indicates if automatic schema synchronization will be performed on each application run. Should be boolean-like value.
* - TYPEORM_AUTO_SCHEMA_SYNC - indicates if automatic schema synchronization will be performed on each application run. Should be boolean-like value.
* - TYPEORM_ENTITIES - list of directories containing entities to load. Should be string - directory names (can be patterns) split by a comma.
* - TYPEORM_SUBSCRIBERS - list of directories containing subscribers to load. Should be string - directory names (can be patterns) split by a comma.
* - TYPEORM_ENTITY_SCHEMAS - list of directories containing entity schemas to load. Should be string - directory names (can be patterns) split by a comma.
Expand Down Expand Up @@ -327,7 +327,7 @@ export class ConnectionManager {
usePool: process.env.TYPEORM_USE_POOL !== undefined ? OrmUtils.toBoolean(process.env.TYPEORM_USE_POOL) : undefined, // special check for defined is required here
extra: process.env.TYPEORM_DRIVER_EXTRA ? JSON.parse(process.env.TYPEORM_DRIVER_EXTRA) : undefined
},
autoSchemaCreate: OrmUtils.toBoolean(process.env.TYPEORM_AUTO_SCHEMA_CREATE),
autoSchemaSync: OrmUtils.toBoolean(process.env.TYPEORM_AUTO_SCHEMA_SYNC),
entities: process.env.TYPEORM_ENTITIES ? process.env.TYPEORM_ENTITIES.split(",") : [],
subscribers: process.env.TYPEORM_SUBSCRIBERS ? process.env.TYPEORM_SUBSCRIBERS.split(",") : [],
entitySchemas: process.env.TYPEORM_ENTITY_SCHEMAS ? process.env.TYPEORM_ENTITY_SCHEMAS.split(",") : [],
Expand Down Expand Up @@ -395,7 +395,7 @@ export class ConnectionManager {
await connection.dropDatabase();

// if option is set - automatically synchronize a schema
if (options.autoSchemaCreate && !process.env.SKIP_SCHEMA_CREATION)
if (options.autoSchemaSync && !process.env.SKIP_SCHEMA_CREATION)
await connection.syncSchema();

return connection;
Expand Down
2 changes: 1 addition & 1 deletion src/connection/ConnectionOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export interface ConnectionOptions {
* This option is useful during debug and development.
* Alternative to it, you can use CLI and run schema:sync command.
*/
readonly autoSchemaCreate?: boolean;
readonly autoSchemaSync?: boolean;

/**
* Environment in which connection will run.
Expand Down
Loading

0 comments on commit 5dc655e

Please sign in to comment.