pomm-project / cli Goto Github PK
View Code? Open in Web Editor NEWCommand line interface for Pomm project.
License: MIT License
Command line interface for Pomm project.
License: MIT License
It would be nice to make SessionBuilder
empty class generation easy.
cmd for build database since a xml or yml or sql file ?
As scrutinizer states, it is not necessary to specify @return
on a constructor in the auto structure classes.
The readme states that generated classes are saved under DatabaseConfigName\SchemaSchema
.
This is a fine default as it works well for both a multi-database & schemata config and a simple single database and schema using PSR-0, but doesn't work for those of us using PSR-4 for our application namespace and wanting to have our entities generated in the same namespace.
I get that using the DatabaseConfigName\SchemaSchema
layout makes sense for multiple schemata and multiple database configurations, but I think it would be nice for a simple application to have generated files in a simpler structure with:
$ ./bin/pomm.php pomm:generate:schema-all --prefix-dir sources/lib --prefix-ns Model pomm_test
✓ Creating file 'sources/lib/Model/AutoStructure/Pika.php'.
…
Where the Pika
class is in the DatabaseConfigName\Model\AutoStructure
namespace (or not? It's just an extra bit to add to --prefix-ns
).
Is this remotely feasible and does it make sense? I thought I'd check before diving in to the code.
The generated model has a reference to the flexible entity class [1]. This class name is quoted with double quotes, which makes the backslash-something characters interpretable. This might lead to defects in referencing classes whenever an escaped character with a special meaning occurs.
Most prominent examples are \n and \t.
[1] https://github.com/pomm-project/Cli/blob/master/sources/lib/Generator/ModelGenerator.php#L129
Pomm's Cli often calls Session::getInspector()
, that actually belong to a more recent version of the Foundation's Session
class coming from the Foundation version referenced in the composer.lock
.
So you need to run composer update
to get those new Session
features.
Not sure about how composer
constraints + following semantic versioning may help preventing this.
I have a table:
CREATE TABLE IF NOT EXISTS orga.activity (
activity_id serial PRIMARY KEY,
name varchar NOT NULL,
project_id int NOT NULL REFERENCES orga.project(project_id) ON DELETE CASCADE
);
Then I rename the primary key:
ALTER TABLE orga.activity RENAME COLUMN id TO activity_id;
And regenerate the AutoStructure files (symfony):
./bin/console pomm:generate:schema-all -d engine -a OrgaBundle model orga
Overwriting file 'engine/OrgaBundle/Model/OrgaSchema/AutoStructure/Activity.php'.
Now if I open AutoStructure/Activity.php I see:
->setRelation('orga.activity')
->setPrimaryKey(['id'])
->addField('activity_id', 'int4')
->addField('name', 'varchar')
->addField('project_id', 'int4')
->addField('id', 'int4') is overwritten with "->addField('activity_id', 'int4')" but the Primary Key isn't overwritten with the new primary key name.
The table seems to have correct structure:
\d activity
Column | Type | Modifiers
-------------+-------------------+-------------------------------------------------------
activity_id | integer | not null default nextval('activity_id_seq'::regclass)
name | character varying | not null
project_id | integer | not null
Indexes:
"activity_pkey" PRIMARY KEY, btree (activity_id)
Foreign-key constraints:
"activity_project_id_fkey" FOREIGN KEY (project_id) REFERENCES project(project_id) ON DELETE CASCADE
In projects, it is advised to create a dedicated SessionBuilder
class. It would be nice the CLI could generate an empty class.
Hello everibody!
Awesome project! Looks very cool!
One question: how can i mirgate my schema and some data with versioning?
Is where something like doctrine-migrations for Pomm?
A command should exist to dump all types registered in the converter holder.
Hello,
I discover a light bug with prefix option, the first slash are remove by ltrim
.
I don't know why ltrim
is there, that should be rtrim
no ? for avoid double slash at right if path end with slash.
# https://github.com/pomm-project/Cli/blob/master/sources/lib/Command/SchemaAwareCommand.php#L138
$elements =
[
ltrim($this->prefix_dir, '/'),
$prefix_ns,
Inflector::studlyCaps($config_name),
Inflector::studlyCaps(sprintf("%s_schema", $this->schema)),
$extra_dir,
sprintf("%s%s.php", Inflector::studlyCaps($file_name), $file_suffix)
];
$ php /app/vendor/bin/pomm.php pomm:generate:schema-all -b /app/.pomm_cli_bootstrap.php \
--prefix-dir /app/src//// \
--prefix-ns "\Plab\Iced\Core" \
--psr4
# with ltrim
app/src/////Model/CatalogSchema/AutoStructure/Attribute.php
# with rtrim
/app/src/Model/CatalogSchema/AutoStructure/Attribute.php
# when ltrim removed
/app/src/////Model/CatalogSchema/AutoStructure/Attribute.php
=> PommProject\Cli\Test\Unit\Command\GenerateEntity::testExecute():
==> Error CATCHABLE FATAL ERROR in /home/travis/build/pomm-project/Cli/sources/tests/Unit/Command/GenerateEntity.php on unknown line, generated by file /home/travis/build/pomm-project/Cli/vendor/pomm-project/model-manager/sources/lib/Generator/BaseGenerator.php on line 54:
Argument 1 passed to PommProject\ModelManager\Generator\BaseGenerator::__construct() must be an instance of PommProject\ModelManager\Session, instance of PommProject\Foundation\Session given, called in /home/travis/build/pomm-project/Cli/sources/lib/Command/GenerateEntity.php on line 85 and defined
It would be nice the CLI could generate empty ModelLayer
class.
inventory.car inherits inventory.inventory. Generated structure file doesn't have primary key
$this
->setRelation('inventory.car')
->setPrimaryKey([])
If we create schema with name "user" cli generator should create relations with escaped schema name as it's reserved word. E.g.
AutoStructure/Table.php should contains ->setRelation('"user".table') instead of ->setRelation('user.table')
I originally created this in wrong project pomm-bundle pomm-project/pomm-bundle#42.
Pomm generates model, structure and other files to directory structure Connectionalias\Schema. If I have only one connection to DB, which I believe is very common scenario, I think that there could be something like "default connction" which will ommit this in namespace and in path. In result there will be only src/AppBundle/Model/ instead of src/AppBundle/Model/Mydb/PublicSchema/.
Currently, entities are generated without any property annotation, so code completion in editors is not supported.
One possibility (in my opinion the cleanest one) would be, to change the entity template like this:
namespace {:namespace:};
use {:flexible_container:};
/**
* {:entity:}
*
* Flexible entity for relation
* {:schema:}.{:relation:}
*
* @see FlexibleEntity
*
* @property String name
* @property Integer ....
*/
class {:entity:} extends {:flexible_container_class:}
{
}
Now $entity->name
is available as a code completion suggestion.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.