throw new OSchemaException("Found invalid property name. Cannot start with numbers");
if (getDatabase().getTransaction().isActive())
throw new OSchemaException("Cannot create a new property inside a transaction");
final ODatabaseRecordInternal database = getDatabase();
database.checkSecurity(ODatabaseSecurityResources.SCHEMA, ORole.PERMISSION_UPDATE);
checkPersistentPropertyType(database, propertyName, type);
OProperty property = null;
acquireSchemaWriteLock();
try {
final StringBuilder cmd = new StringBuilder("create property ");
// CLASS.PROPERTY NAME
cmd.append(name);
cmd.append('.');
cmd.append(propertyName);
// TYPE
cmd.append(' ');
cmd.append(type.name);
if (linkedType != null) {
// TYPE
cmd.append(' ');
cmd.append(linkedType.name);
} else if (linkedClass != null) {
// TYPE
cmd.append(' ');
cmd.append(linkedClass.getName());
}
final OStorage storage = database.getStorage();
if (storage instanceof OStorageProxy) {
database.command(new OCommandSQL(cmd.toString())).execute();
reload();
return getProperty(propertyName);
} else if (isDistributedCommand()) {
final OCommandSQL commandSQL = new OCommandSQL(cmd.toString());
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(commandSQL).execute();
property = addPropertyInternal(propertyName, type, linkedType, linkedClass);
} else
property = addPropertyInternal(propertyName, type, linkedType, linkedClass);