Is the schema of a GRANDstack app using the Neo4j-GraphQL integration fixed at deployment or can a structure my app such that users could modify the schema and still have the autogenerated resolvers?
The database model is driven by the GraphQL schema, so if you change the GraphQL schema, the inferred database datamodel will be adjusted accordingly. How would you expose the functionality for users to modify the schema? What use case do you have in mind for that?
Related
How to re-use same database with different migration scripts for different rails apps. The following is the proposed structure, is this something which would work and is this a proper way to share the database?
rails-app1/db/migrate/s1.sql
rails-app1/db/migrate/s4.sql
rails-app2/db/migrate/s2.sql
rails-app2/db/migrate/s3.sql
rails-app2/db/migrate/s5.sql
I am using MySQL database
Maybe you should consider to create an API which will be the only one with rights to read/write in your database. Then, App1 and App2 will be consumers of this API.
What you are trying to do will create different database schemes with different (or duplicated) model definitions for the same Database... It sounds dangerous.
I'm working on a web site that needs to be re-written in Rails. The website was before in Drupal, and there are almost 100,000 records in the database. Now, in Drupal there are tables that do not make any place in Rails in my opinion. For example,
Table name: node_type
It stores information regarding modules in Drupal.
Table name: node
It stores information for node(s) in Drupal.
Table name: semaphore # I've no idea what it is!
Table name: rdf_mapping # No idea
I've not been working with Drupal, so all I want to ask: Is it possible to have a schema for Rails, in which the existing 100,000 records can be imported from Drupal? If so, how? If not so, what are the other options that I'm left with? Or I have to design an entirely new database schema?
Drupal's database schema is not extensively documented for a reason... it's considered implementation details, is not a public API and should not be accessed directly, especially by outside application.
It is also very hard to document because for a given site, any enabled module can add its own tables and alter existing ones (usually adding columns). Plus you have module like Fields (part of Drupal core) that create tables dynamically depending on defined content types.
For a RoR developer, the Drupal schema will probably look weird and be uncomfortable to work with. I would follow suggestion from others, create a new schema for your new application and create a migration script to get the data from the old Drupal database to your new database. I don't knwon about RoR, but try to find a good data migration that allows replay, updates and rollback, etc. You will probably have to migrate the data multiple times to fixes bugs in the process.
Well, I don't have straight forward answers, but I have some ideas what I would do simply to not make so much changes in the database, or as per the comment you can write down an sql script to migrate the data according to the rails schema like types for each tables. Now, I am just intended here to share my thoughts, but I believe there might be more explicit solutions and this is do-able in many ways, may be you need some customizations(?) overriding the default conventions. According to my thoughts, you can try the following things.
Generated Related model skipping migrations
Define tables explicitly to each models like the following snippets:
class Semaphore < ActiveRecord::Base
self.table_name = "semaphore"
end
You have to define foreign keys and primary keys explicitly for both record id and associations.
You have generate time stamp or you can explicitly avoid that like the following ways
ActiveRecord::Base.record_timestamps = false
These are basic things I can see is important.
I'm considering Grails for my next project, but I will be given a complete database before I start writing the application around it. I have read that Grails is a domain-centric environment, supporting top-down development, so that does not fit my development mode.
Hence my question: is it possible to write a Grails app around an existing DB structure? What would be the best approach? Can Grails be used without a full ORM, but with a pattern like ActiveRecord? Or are there tools to generate Grails classes from an existing DB schema?
are there tools to generate Grails classes from an existing DB schema?
Grails Reverse Engineering Plugin
Yes Grails can be used without an ORM.
We have written non-GORM domain classes that fetch their data from RESTful APIs without ever going to a permanent storage. So Grails is in no way forcing you to use GORM.
Depending on your legacy DB schema you can either just add params to your GORM classes to fit that schema or you can just write your own data accessors for your database.
Giving further tips / ideas without further information regarding your project and database schema is impossible, so I'll leave it at that :)
I am presently designing a database schema for use in a Rails 3.1 application.
At the moment, I am using MySQL Workbench to design the schema visually, and then manually translating this to Rails migrations & models.
Can anyone indicate if there are any solutions that will allow a schema to be designed visually and translated automatically (i.e. via script) to Rails?
Thanks!
First off, the "database-first" approach definitely isn't really the preferred way to work with Rails... but if you really want to...
If you generate the the tables from your schema you can configure the Rails app's config/database.yml file to connect to your database, then call rake db:schema:dump which generates the db/schema.rb file from the database. Then you can create a migration and copy the code from db/schema.rb into the change (or self.up) method.
Note that this does not automatically create model classes - you'll have to create these yourself, remembering to --skip migration in the rails generate model, and possibly needing to make liberal use of the set_table_name (to map the model class to the right table name), alias_attribute (to map model attributes to the right columns), and perhaps set_primary_key.
There were some more complete approaches to this sort of thing for older versions of Rails (Magic Model Generator and reverse_scaffold are two that I've found), but I don't know of any that have been upgraded to work with Rails 3.
SQL Editor is a Mac application that allows you to visually design a DB schema and then export it as something you can easily import as a schema in Rails.
You will still have to create the models yourself.
For rails existing applications or the new application, you can use this for db design
https://dbdiagram.io/
I use railshelper.com which helps me in a simplistic manner to generate quickly some common rails cli commands !
I think Mogwai ERD will help you out, there you can design your ERD and convert it in to a DB schema.
And I think there is no software for design Rails schema, it's just that you make your schema adhere to Rails conventions. But of course Rails can be configured to almost any schema.
I was told that for some reason, you can't update a database schema when using rails. You can drop a table and then recreate a table with an updated schema, but this won't work if you already have content stored in the table that you want to update.
What do you recommend?
Thanks!
What you were told is incorrect. You can update a DB schema when using Rails.
The way you do it is through "migrations."
A common pattern is to write a set of migrations that build your initial schema. As your app develops, you write other migrations that change the tables and columns to suit the evolving design. If the app is in production, you apply these new migrations to the production schema.
Of course some changes will mess up your existing data, but that has nothing to do with Rails. That would be true regardless of what programming language/framework you're using.
If you have a legacy DB schema and are not using migrations, you can still update your schema by interacting directly with the DB server. Again, what will work and what won't in that situation has nothing to do with Rails. It's totally up to the structure of the schema and the data itself.
If you drop a table in the content in it, the content will be destroyed. You can, however, include content migrations alongside db schema migrations, so it will be migrated back to the table once the schema is updated.