How can I rename a table in "Directus" CMS(https://getdirectus.com)?
I tried renaming the name from the admin portal but it does not work. There is a clear messages written under the "name":
Can not (currently) be changed within the CMS.
Directus table
Is there any workaround to change it?
Unfortunately there is no way to rename a table in Directus version 6.x. This is because the table name would also need to be updated throughout many instances within Settings. Version 7.0 (release in Q2-2018) will have the ability to rename tables and the update will cascade throughout the system.
For now, you can manually make this change directly in the database. First, update the actual table name, then change any references to it within idrectus_tables, directus_columns and directus_privileges. You can also update directus_activity, but only if you need to maintain existing revisions/history for that table.
Related
Since TYPO3 uses doctrine it is possible to use tables from multiple databases in one instance (with some restrictions like no joins).
But what is possible at all?
At the moment I need two external tables for an extension and instead of using them directly I import them to work locally as usual. But the importing has some draw backs.
Draw backs I can accept:
the data is not live (changes to the external tables are imported later)
the data is read only (changes are done externally anyway)
For importing I use ext:external_import but there are some problems as not all data can be imported in a single run, and then there are errors (e.g. there are reports about duplicate keys, alas there are no duplicate keys in the external tables)
On the other hand I doubt I can use the external tables directly as they have not the usual TYPO3 structure (fields: 'uid', 'pid', 'tstamp', ...). (Maybe they can be mapped in a view?) (of course in the tables I import the data into these fields exist)
Also external changes may be unnoticed and cached content does not reflect current data. In my case that would be a minor problem, as we currently already have no 'live' data, but this needs to be cleaned regularly for cache and for the search index (solr).
What are possible solutions? ? (do they depend on the TYPO3 version?)
What are your experiences?
EDIT:
While trying to realize it considering the given answers more doubts appear:
the tables are readonly (as they are changed from outside):
How do I declare it to TYPO3?
the tables does not follow the usual name rules, especially one table is named sys_category which in this way conflicts with the TYPO3 table sys_category.
Can I build a mapping inside of TYPO3?
Can I build a view from TYPO3 for renaming tables and fields?
like:
CREATE View tx_myext_category
SELECT id as uid, name as title, ...
FROM databasename.sys_category;
Yes, you can fetch data directly from other databases/tables. Of course it highly depends on the usecases and the data you get:
It works fine to read/write data by using the queryBuilder and all the APIs you know from https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Database/Index.html like ConnectionPool, QueryBuilder
If you want to show the data in the formengine, e.g. list module, you will need to have the minimum columns like uid, pid and a valid TCA as well.
From my experience, the mapping mechanism only works if the external table has a almost similar structure as TYPO3 tables. You need at least a uid field on the external side. This cannot be mapped! A missing pid field could be managed with on the TYPO3 side, also crdate or tstamp if needed. Just fill the local data array with the values TYPO3 needs.
Problems arise if you have relations to deal with. Many external systems have other ways to handle relations. You could run into many problems if you try to rely only on the mapping mechanism.
Other problems are fields with date format. Most external tables in the MS world use another format as the unixtime.
If you run into problems with the mapping mechanism you can switch to the TYPO3 queryBuilder. This is a powerful fallback. I experienced problems only with a special type of JOIN statements.
But with the TYPO3 queryBuilder you are on your own. You place instances of the queryBuilder code in the repository and add your model code as usual: thus you can continue to work with Fluid in the frontend as you are used to.
ANSWER TO EDIT:
With the TYPO3 queryBuilder readonly tables aren't a problem. Just don't implement the setter classes in your models.
With TYPO3 queryBuilder you can call any external table with any name. You have full control over the output data in your repository because the mapping is handled inside of it.
As far as I know, there is no way to create SQL views in TYPO3 up to v9, neither with the DBAL mapping mechanism nor with the TYPO3. queryBuilder.
My question is that if the tables are removed for whatever reason, is it possible to automatically add tables at runtime before object to table.
Thanks
If I have a Grails application which I have used to persist some domain objects to my database (MongoDb in this case but probably does not matter), and I modify my domain class, say I add some more properties or take some properties away. Now, will the modified version of the application with the newer version of the domain class still recognize the already persisted old version of the domain instances?
More importantly if I now restart the Grails application with the new version of the domain class, will it delete(or do anything to) the already persisted old versions of the domain objects? I am trying to chase a similar issue I am facing but I am on a team so I'm not sure if the application deleted the old objects from the db (which I don't think so) or did some human system user.
The way in which Grails handles the database depends on the value of the dbCreate property in DataSource.groovy.
If you declare
dataSource {
dbCreate = "update"
}
then any additional properties you add to your domain class will be added as columns in your database. Note that this will not delete any columns that already exist. So say you had a property called x and wanted to replace it with a property called y, this would create a y column in the database but the x column would still remain.
Here a list of the possible values and behaviors for dbCreate
create - Drops the existing schema. Creates the schema on startup, dropping existing tables, indexes, etc. first.
create-drop - Same as create, but also drops the tables when the application shuts down cleanly.
update - Creates missing tables and indexes, and updates the current schema without dropping any tables or data. Note that this can't properly handle many schema changes like column renames (you're left with the old column containing the existing data).
validate - Makes no changes to your database. Compares the configuration with the existing database schema and reports warnings.
any other value - does nothing
Hope this helps
I have to migrate my custom system to typo3 version 6.2 but I did not find any database diagram(design/schema) of typo3. Would be great if someone can help. Thank you.
In a TYPO3 installation without extensions, there are not many tables that will interest you. Interesting tables are
pages and pages_language_overlay: Pages and their translations.
tt_content: Content, translations are in the same table.
sys_language: Define available languages. For pages with only a default language it can stay empty.
sys_domain: Define Domains under which a site is available. For single domain installations it can be left empty.
sys_file_reference: References to files, which are stored in table sys_files. The table sys_files will be automatically filled when you put files into the fileadmin folder.
fe_users and fe_groups: Frontend users and groups.
The other tables are either caching tables (names start with cf_) or are mostly used internally (most tables having names starting with sys_).
In some of the tables, especially in pages and tt_content, there are deprecated fields.
The usage of some fields depends on the actual TYPO3 setup. For example, the text of a content element from tt_content could be stored in the field bodytext, or in the field pi_flexform. So the question how to import your data depends on your setup.
For further information have a look at the official docs: https://docs.typo3.org/typo3cms/CoreApiReference/latest/ApiOverview/Database/DatabaseStructure/Index.html
I don't have a diagram either, but this note is too long for a comment:
Most M:N relationships (e.g. users & groups) are handled with foreign key attributes stored as comma-separated entries inside table cells, inside rows of the parent table. Of course, this nonatomic way of storing data violates first-normal form of database-table design.
However, some newer extensions do rely on bridge tables. In typo3, this is called an M:M relation, and some tables have a naming corresponding convention, e.g. tt_news_cat_mm, linking news-messages with news-categories.
I want to create a Typo3 plugin that can be used as a content type on pages (i.e. FE plugin), without any user input. The plugin would generate content from additional tables in the typo3 database. The content for these tables is inserted outside of typo3.
From what I understand, I have to do the following:
ext_tables.php: The TCA configuration is used for configuring how fields can be edited in the Back End. Since the user must not enter any data, I will not need this
ext_tables.sql: Write the CREATE statements for my tables. This will update the typo3 database and keep it in synch with this definition on updates
Are there any other configuration files I have to edit?
What about views? Does Typo3 understand CREATE VIEW statements in the ext_table.sql?
Thanks for any hints!
if you don't need to create a table for your extension you don't need to worry about linking them up on ext_tables.php. I would just write your code into the pi1.php file, querying the desired table and outputting the result.
The file where your code sits is usually on
pi1/class.tx_myextension_pi1.php