mirror of
https://github.com/silverqx/TinyORM.git
synced 2026-05-01 06:00:08 -05:00
made methods static
This commit is contained in:
@@ -37,26 +37,26 @@ namespace Tom
|
||||
|
||||
protected:
|
||||
/*! Get the migration stub file. */
|
||||
QString getStub(const QString &table, bool create) const;
|
||||
static QString getStub(const QString &table, bool create);
|
||||
|
||||
/*! Get the full path to the migration. */
|
||||
fspath getPath(std::string &&datetimePrefix, const QString &name,
|
||||
std::string &&extension, const fspath &path) const;
|
||||
/*! Get the date prefix for the migration. */
|
||||
std::string getDatePrefix() const;
|
||||
static std::string getDatePrefix();
|
||||
|
||||
/*! Populate the place-holders in the migration stub. */
|
||||
std::string populateStub(const QString &name, QString &&stub,
|
||||
const QString &table) const;
|
||||
static std::string
|
||||
populateStub(const QString &name, QString &&stub, const QString &table);
|
||||
/*! Get the class name of a migration name. */
|
||||
QString getClassName(const QString &name) const;
|
||||
static QString getClassName(const QString &name);
|
||||
/*! Ensure a directory exists. */
|
||||
void ensureDirectoryExists(const fspath &path) const;
|
||||
static void ensureDirectoryExists(const fspath &path);
|
||||
|
||||
private:
|
||||
/*! Ensure that a migration with the given name doesn't already exist. */
|
||||
void throwIfMigrationAlreadyExists(const QString &name,
|
||||
const fspath &migrationsPath) const;
|
||||
static void throwIfMigrationAlreadyExists(const QString &name,
|
||||
const fspath &migrationsPath);
|
||||
};
|
||||
|
||||
} // namespace Tom
|
||||
|
||||
@@ -53,7 +53,7 @@ fspath MigrationCreator::create(
|
||||
|
||||
/* protected */
|
||||
|
||||
QString MigrationCreator::getStub(const QString &table, const bool create) const
|
||||
QString MigrationCreator::getStub(const QString &table, const bool create)
|
||||
{
|
||||
QString stub;
|
||||
|
||||
@@ -82,13 +82,13 @@ fspath MigrationCreator::getPath(std::string &&datetimePrefix, const QString &na
|
||||
return path / std::move(filename);
|
||||
}
|
||||
|
||||
std::string MigrationCreator::getDatePrefix() const
|
||||
std::string MigrationCreator::getDatePrefix()
|
||||
{
|
||||
return QDateTime::currentDateTime().toString(DateTimePrefix).toStdString();
|
||||
}
|
||||
|
||||
std::string MigrationCreator::populateStub(const QString &name, QString &&stub,
|
||||
const QString &table) const
|
||||
std::string
|
||||
MigrationCreator::populateStub(const QString &name, QString &&stub, const QString &table)
|
||||
{
|
||||
const auto className = getClassName(name);
|
||||
|
||||
@@ -107,12 +107,12 @@ std::string MigrationCreator::populateStub(const QString &name, QString &&stub,
|
||||
return stub.toStdString();
|
||||
}
|
||||
|
||||
QString MigrationCreator::getClassName(const QString &name) const
|
||||
QString MigrationCreator::getClassName(const QString &name)
|
||||
{
|
||||
return StringUtils::studly(name);
|
||||
}
|
||||
|
||||
void MigrationCreator::ensureDirectoryExists(const fspath &path) const
|
||||
void MigrationCreator::ensureDirectoryExists(const fspath &path)
|
||||
{
|
||||
if (fs::exists(path) && fs::is_directory(path))
|
||||
return;
|
||||
@@ -123,7 +123,7 @@ void MigrationCreator::ensureDirectoryExists(const fspath &path) const
|
||||
/* private */
|
||||
|
||||
void MigrationCreator::throwIfMigrationAlreadyExists(const QString &name,
|
||||
const fspath &migrationsPath) const
|
||||
const fspath &migrationsPath)
|
||||
{
|
||||
// Nothing to check
|
||||
if (!fs::exists(migrationsPath))
|
||||
|
||||
Reference in New Issue
Block a user